Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa HTML code for jsp to db connection using jdbc
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


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


please send me the code


Advertisement
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: 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
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 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
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
Draw graph using jsp without database connection
Draw graph using jsp without database connection  Draw graph using jsp code without database connection
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
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
Todd oracle DB connection through PHP
Todd oracle DB connection through PHP  Can u please explain how to connect Todd oracle DB using PHP & What are the setups we need to perform? Thanks
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
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
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
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
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
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
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
tree using jsp code
tree using jsp code  i want to draw a tree structure of a family hierarchy using jsp code
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
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
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
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..."); Connection con = DriverManager.getConnection("jdbc:odbc:student
JDBC connection pooling
JDBC connection pooling  What is Connection pooling
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? 
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
j2me jdbc connection - JDBC
j2me jdbc connection  hello, whn i m importing sql package in mine midlet(tried for both javax.sql.* and java.sql.*;)..itz nt accepting it... hw to get connected to database?????.... plz help me out
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
JSP,DB,SERVLET
JSP,DB,SERVLET  hi thank you for your reply.With this code i can..."); Connection con = DriverManager.getConnection("jdbc:odbc:student"); Statement st..."); Connection con = DriverManager.getConnection("jdbc:odbc:student
 

 

 

DMCA.com