code for jsp to db connection using jdbc

code for jsp to db connection using jdbc

please send me the code

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:

<%@page 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.... <%@page 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

<%@page 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());
}
%>









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:ADS_TO_REPLACE_1 1)form.html: <html> <form method="post" action="http://localhost:8080/examples/jsp
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
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
tree using jsp code
tree using jsp code  i want to draw a tree structure of a family hierarchy using jsp code
JDBC Connection code to connect servlet with oracle.
JDBC Connection code to connect servlet with oracle.  JDBC Connection code to connect servlet with oracle
Draw graph using jsp without database connection
Draw graph using jsp without database connection  Draw graph using jsp code without database connection
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
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
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
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
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
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
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
jsp fie execution in tomcat and using mysql - JDBC
jsp fie execution in tomcat and using mysql  I created 2 jsp files... The username and password that we used in the JDBC Connection...:THE LAST JSP PAGE IS COMING DIRECTLY ON EXECUTION IN TOMCAT
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
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
populating text box using jsp code
. Please give an example using jsp code only.   dependentDropdown.jsp...populating text box using jsp code  Sir, How to populate related values in a text box after selecting value from drop down list using JSP and mysql
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:ADS...); try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection con
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
code for password strength using jsp-servlet
code for password strength using jsp-servlet  hi.............. plz help me to give code for password strength using jsp-servlet for implementation in my project as soon as possible because i want to show this functionality in my
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
code to send sms alerts using jsp online
code to send sms alerts using jsp online  I am new to mobile aplication development. pls send me the code for sms alerts after clicking the button
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
"); Connection con = (Connection) DriverManager.getConnection("jdbc:mysql://127.0.0.1...jdbc connection  How to Submit data????   <%-- view jsp --%> <%@page import="java.sql.Statement"%> <%@page import
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
JSP,DB
"); Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/test...JSP,DB  How to store the resultset of a query in a hashtable n retrive it into a jsp textfield!!!!!! datatable Label value id applno
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
JDBC connection pooling
JDBC connection pooling  What is Connection pooling
connection with database - JSP-Servlet
and the connection with the database using jsp code, I get exceptions that I have... with java code. Is there any other way to establish a connection with database in jsp... Friend, Try the following code: Send your JSP code, if you get
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
Insert a row in 'Mysql' table using JSP Code
Insert a row in 'Mysql' table using JSP Code In this section, we will discuss about how to insert data in Mysql database using JSP code. Query... between your Tomcat server & Mysql database Table. Code to insert row in Mysql
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
Source Code for Implementing Search Feature in JSF/JSP using Servlet - Java Beginners
Source Code for Implementing Search Feature in JSF/JSP using Servlet  How do I write the source code to implement search feature in JSF/JSP using..."); PrintWriter pw = response.getWriter(); Connection con = null; String url = "jdbc
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
can any one give the frogort password code using jsp,
can any one give the frogort password code using jsp,  plz give the code for frogot password
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 Mysql Connection Url
JDBC Mysql Connection. In this program, the code explain the JDBC url and string... JDBC Mysql Connection Url      ... for built a connection between a url and database.On execution of code, The println show
How to use next and previous button(or href) for database table that is retrieved from MySQL DB using jsp,jstl,javascript
that is retrieved from MySQL DB using jsp,jstl,javascript  when click on the next...://www.roseindia.net/jsp/navigation-database-table.shtml   follow this code..._name where id=..; database:mysql technology:jsp,servlet,javascript,jstl  
retriving data from sql server using jsp code and placing them in text fields of html code
retriving data from sql server using jsp code and placing them in text fields... server 2008 using a jsp file and place the values in the text fields of a html file... in the addclients table. can anyone plese send me the jsp code to retrieve
how to access element added via javascript dynamically using jsp code
javascript dynamically using the jsp code. i am adding empty records on .jsp page...how to access element added via javascript dynamically using jsp code ... not able to access these dynamically added textboxes values from my jsp code
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? 
Connection to jdbc - Java Beginners
Connection to jdbc  I need to populate a listbox in jsp with values from Postgresql JDBC. i used the following code... but its not working... can..., We have used Mysql database. Try the following code
Common connection in JSP - JSP-Servlet
Common connection in JSP  Hi I am creating an JSP application. I... connection to database. I am able to get connection in other(common) JSP, but not able to use that "Connection conn" into other JSP pages . How do i access
Read code from excel sheet and upload into database using JSP
Read code from excel sheet and upload into database using JSP  I want to upload data to database from an excel worksheet using jsp ...Please help
JSP code
JSP code  I get an error when i execute the following code : <..."); 19: Connection con = DriverManager.getConnection("jdbc:oracle:thin:@localhost...("oracle.jdbc.driver.OracleDriver"); Connection con = DriverManager.getConnection("jdbc
Help on JSP and JDBC - JDBC
Help on JSP and JDBC  Retrieve data from Database in JSP and JDBC...;% Connection con = null; String url = "jdbc:mysql://localhost:3306/"... combine databse code and jsp, it is not good approach,use separate class
how to generate reports from oracle database using jsp and ajax code
how to generate reports from oracle database using jsp and ajax code  ... sales report data from oracle database to jsp page please any one know how to do this send me a code to my email:[email protected] its a humble request my team
JSP,DB,SERVLET
JSP,DB,SERVLET  hi thank you for your reply.With this code i can... the code for the same scenario using for populating data into database through...("sun.jdbc.odbc.JdbcOdbcDriver"); Connection con = DriverManager.getConnection("jdbc:odbc

Ads