code for jsp to db connection using jdbc

Ads

 
 

Share on Google+Share on Google+

anjali pathuri
code for jsp to db connection using jdbc
4 Answer(s)      6 years and 9 months ago
Posted in : HTML

please send me the code

Ads
View Answers

December 6, 2010 at 12:35 PM


Hi Friend,

Try the following code:

1)form.html:

<html>
<form method="post" action="http://localhost:8080/examples/jsp/insert.jsp">
<table>
<tr><td>Name:</td><td><input type="text" name="name"></td></tr>
<tr><td>Address:</td><td><input type="text" name="address"></td></tr>
<tr><td></td><td><input type="submit" value="Submit"></td></tr>
</table>
</form>
</html>

2)insert.jsp:

<[email protected] import="java.sql.*"%>
<%
String name=request.getParameter("name");
String address=request.getParameter("address");
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
           Connection con = DriverManager.getConnection("jdbc:odbc:student");
           Statement st=con.createStatement();
           int i=st.executeUpdate("insert into user(name,address) values('"+name+"','"+address+"')");
           out.println("Data is inserted successfully");
%>

Thanks



May 6, 2013 at 9:10 PM


('"+name+"','"+address+"')"); here i m getting problem... it shows error... that 'operator + can not be applied to java.lang.String,name can not find symbol.... plzz help me...



May 8, 2013 at 12:57 PM


the insert.jsp code is not working... Becoz of there is no try catch block.... <[email protected] import="java.sql.*"%> is not enough.. it shud be

<%@ page language="java" import="java.sql.,java.util.,java.text.*" %>

--Rohit Soni



November 27, 2013 at 2:19 PM


Thank You Very much Miss anjali pathuri for this code:

I have included Try-Catch Block in insert.jsp Page

<[email protected] import="java.sql.*"%>
<%
String name=request.getParameter("name");
String address=request.getParameter("address");
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection("jdbc:odbc:student","sa","password0");
Statement st=con.createStatement();
st.executeUpdate("insert into users(name,address) values('"+name+"','"+address+"')");
out.println("Data is inserted successfully");
}
catch(Exception ex)
{
out.println(ex.getMessage());
}
%>


Ads









Related Tutorials/Questions & Answers:
code for jsp to db connection using jdbc
code for jsp to db connection using jdbc  please send me the code   Hi Friend, Try the following code: 1)form.html: <html> <...("sun.jdbc.odbc.JdbcOdbcDriver"); Connection con = DriverManager.getConnection("jdbc:odbc
Server DB connection - JDBC
get it to work. If you have any sample code for getting connection please...Server DB connection  Hello Guys I want to connect two databases at the same time but it looks like the java is only picking up the second database
Advertisements
JDBC Connection code to connect servlet with oracle.
JDBC Connection code to connect servlet with oracle.  JDBC Connection code to connect servlet with oracle
online quiz program coding using jsp, jdbc odbc connection with ms. access.. Thank you.
online quiz program coding using jsp, jdbc odbc connection with ms. access.. Thank you.  please provide online quiz program coding using jsp, jdbc...").newInstance(); Connection connection = DriverManager.getConnection("jdbc:mysql
jdbc connection to java program code - JDBC
jdbc connection to java program code  i want a simple java program that which communicates with oracle database like creating table,insert values and update records in database and show in program output? please take a simple
Draw graph using jsp without database connection
Draw graph using jsp without database connection  Draw graph using jsp code without database connection
JDBC connection
we illustrates you JDBC url connection. The current Tutorial helps you to understand JDBC connection. The code explains you   how... JDBC connection       The JDBC
upload csv to mysql db using jsp upload
upload csv to mysql db using jsp upload  Hello all, Please give me the code to uplad .csv from jsp page and insert values into MySQl db. I have a table with 8 cloumns.(MDN--varchar(30),Otafdate date,crt varchar(30),dmdn
tree using jsp code
tree using jsp code  i want to draw a tree structure of a family hierarchy using jsp code
online shopping code using jsp
online shopping code using jsp  plz send me the code of online shopping using jsp or jdbc or servlets plz plz help me
jsp to cassandra datbase connection by using eclipse
jsp to cassandra datbase connection by using eclipse  sir i want to connect the apache cassandra datbase by using cql query language. i am success by using simple java application.now my task is to interact with cassandra
How to design https connection page using JSP
How to design https connection page using JSP  Hi, I have a project... a secure page. Please kindly provide me a solution on how to design a https page using JSP Thank you
How to insert data from a combobox and textbox values into DB using JSP?
How to insert data from a combobox and textbox values into DB using JSP?  hi, How to insert a comb-box and a text box values in to DB using JSP? @DB... and textbox2? into MYSQL DB
JDBC Connection code to connect servlet with SQL Server 2008
JDBC Connection code to connect servlet with SQL Server 2008  Please... support for JDBC 4.0. i try Avery thing but i m not success so please ans me . My connection code is static Connection con; static Statement st; static
jdbc connection
"); Connection con = (Connection) DriverManager.getConnection("jdbc:mysql://127.0.0.1...jdbc connection  How to Submit data????   <%-- view jsp --%> <[email protected] import="java.sql.Statement"%> <[email protected] import
Storing and retrieving data alongwith image in mysql db using jsp
Storing and retrieving data alongwith image in mysql db using jsp  I want to store and retrieve the whole data as shown below in mysql db. I've put...", "root"); Connection con = DriverManager.getConnection("jdbc:mysql:///test","root
code to establish jdbc database connectivity in jsp
code to establish jdbc database connectivity in jsp  Dear sir, i'm in need of code and procedure to establish jdbc connectivity in jsp
code to establish jdbc database connectivity in jsp
code to establish jdbc database connectivity in jsp  Dear sir, i'm in need of code and procedure to establish jdbc connectivity in jsp
connection - JDBC
connection  how to connect server pages to mysql  Hi Friend, To learn how to connect MySql to JSP, please visit the following link: http://www.roseindia.net/jsp/connect-jsp-mysql.shtml Thanks
javax. servlet.Servlet Exception: Initialization failed, Unable to get DB connection - JSP-Servlet
ServletException("Initialization failed, Unable to get DB connection...javax. servlet.Servlet Exception: Initialization failed, Unable to get DB connection  Hi.i am beginner. using eclipse. i am sure my deployment
JDBC connection
JDBC connection  ![alt text][1]I got exception in Connecting to a MySQL Database in Java. The exception is ClassNotFoundException:com.mysql.jdbc.Driver wat is the problem
JDBC connection and SQL Query - JDBC
JDBC connection and SQL Query  Hi, I'm reading a all files one... DB. But I'm trying hard to figure out syntax for inserting into a table using...]. In short I read values in array of temp, and I need to insert into DB using those
HTML code to servlet to database using jdbc
HTML code to servlet to database using jdbc  pls send me the code related to the title   Hi Friend, Try the following code: 1)form.html... { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection con
jsp fie execution in tomcat and using mysql - JDBC
jsp fie execution in tomcat and using mysql  I created 2 jsp files..., There is a problem in both JSP pages. If you want to login,try the following code: 1... that we used in the JDBC Connection are the MySql username and password.The
How to get data from DB in to Text box by using Jsp & Ajax
How to get data from DB in to Text box by using Jsp & Ajax   I want to get the data from database in to text box in a jsp page by using Ajax. If I enter the letter A in the textbox it should show only those values which starts
jdbc connection issues
tables with only one jdbc connection program...if possiable pls post a sample code...jdbc connection issues  Hello. kindly pls help in this issue...i have created 11 jsp form wit some attributs in it also created 11 tables
database connectivity using jsp code
database connectivity using jsp code  i have two tables employee...),'bbbb','bbbb'); so this syntax is possible to use in jsp code based on employee id ename and designation are displayed how it is possible in jsp employee
JDBC connection pooling
JDBC connection pooling  What is Connection pooling
courier management service (using servlets,jsp,jdbc)
courier management service (using servlets,jsp,jdbc)   is anyone having information about courier management service ? plz share it .its urgent THANKING YOU IN ADVANCE
JDBC connection timeout
The code include a class JDBC Connection Timeout, inside the main method we include... JDBC connection timeout       The Tutorial describe you a JDBC Connection timeout. In this program, we
Java-Connection Pool - JDBC
= "jdbc:mysql://localhost:3306/"; String db = "register"...Java-Connection Pool  How can I create a connection pool. My database... is Weblogic 8. Which is the best approach to create a connection pool?