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



Home Answers Viewqa JDBC to store form vaues in database
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


vijay
to store form vaues in database
1 Answer(s)      6 years and 2 months ago
Posted in : JDBC



Advertisement
View Answers

October 17, 2008 at 4:16 PM


Hi friend,



Code to insert the data into database :

<%@ page import="java.sql.*" %>
<%@ page import="java.io.*" %> 

<HTML>
<HEAD>
<TITLE>Navigating in a Database Table </TITLE>
</HEAD>

<BODY bgcolor="#ffffcc">
<font size="+3" color="green"><br>Welcome in www.roseindia.net !</font>
<FORM action="" method="post">
<TABLE style="background-color: #ECE5B6;" WIDTH="30%" >

<TR>
<TH width="50%">Name</TH>
<TD width="50%"><INPUT TYPE="text" NAME="name"></TD>
</tr>
<TR>
<TH width="50%">Father Name</TH>
<TD width="50%"><INPUT TYPE="text" NAME="father_Name"></TD>
</tr>

<TR>
<TH></TH>
<TD width="50%"><INPUT TYPE="submit" VALUE="submit"></TD>
</tr>
</TABLE>
<%
String name = request.getParameter("name");
String father_Name = request.getParameter("father_Name");



/* Create string of connection url within specified format with machine name,
port number and database name. Here machine name id localhost and database name is student. */
String connectionURL = "jdbc:mysql://localhost:3306/student";;

// declare a connection by using Connection interface
Connection connection = null;

// declare object of Statement interface that uses for executing sql statements.
PreparedStatement pstatement = null;

// Load JBBC driver "com.mysql.jdbc.Driver"

int updateQuery = 0;

// check if the text box is empty
if(name!=null && father_Name!=null ){

// check if the text box having only blank spaces
if(name!="" && father_Name!="") {

try {

Class.forName("com.mysql.jdbc.Driver").newInstance();

/* Create a connection by using getConnection() method that takes
parameters of string type connection url, user name and password to connect
to database. */
connection = DriverManager.getConnection(connectionURL, "root", "root");

// sql query to insert values in the secified table.
String queryString = "INSERT INTO stu_info(Name,Father_Name) VALUES (?, ?)";

System.out.println("queryString : " + queryString);
/* createStatement() is used for create statement object that is used for
sending sql statements to the specified database. */
pstatement = connection.prepareStatement(queryString);
pstatement.setString(1, name);
pstatement.setString(2, father_Name);
updateQuery = pstatement.executeUpdate();

if (updateQuery != 0) { %>
<br>
<TABLE style="background-color: #E3E4FA;" WIDTH="30%" border="1">
<tr><th>Data is inserted successfully in database.</th></tr>
</table>
<%
}
}
catch (Exception ex) {
out.println(ex.getMessage());

}
finally {
// close all the connections.
pstatement.close();
connection.close();
}
}
}
%>
</FORM>
</body>
</html>

For more information visit to :

http://www.roseindia.net/



Thanks


Related Tutorials/Questions & Answers:
to store form vaues in database - JDBC
to store form vaues in database  sir i have created one form with two... the code   Hi friend, Code to insert the data into database :   Navigating in a Database Table Welcome
send multiple textbox vaues in to an jsp form to store them in a DB table
send multiple textbox vaues in to an jsp form to store them in a DB table ... values in to an jsp file with additional values to store those values in to an database table. Please help me...... looking forward to hear from you
Advertisements
Need Solution to get vaues from sql database in java
Need Solution to get vaues from sql database in java  hi I have... need to get values from sql database for values in the blank field(" "). how do i get these values.. already connected database and created xml tags in separate
Solution to get vaues for xml tags fform sql database in java
Solution to get vaues for xml tags fform sql database in java  hi I...; now i need to get values from sql database for values in the blank field(" "). how do i get these values.. already connected database and created xml tags
store form data into word document
store form data into word document  i want form page data, ex username phone number.. to store it in a word document file
How to store image into database
How to store image into database  Hi, all I want to store image into database using Java. Can anyone help me that how can i store image into database using Java. Thanks in advance.   hi friend, To store image
image store in database - JDBC
to store image into database. Check at http://www.roseindia.net/servlets/insert...image store in database  Dear Deepak Sir, If I want to store image into the database what is the process to do that? Please explain
Unable to store the image into database
Unable to store the image into database  Hello, I have created below... of image. I have debug the JSP program and found that HTML form pass only image... ###################################### CREATE TABLE IMAGEMAIN(ID INTEGER,IMAGE BLOB) ; ################## HTML Form
store pagination form fields - Struts
store pagination form fields   hi,iam working online exams project . my intention is to save data that has been asnwered by client/student into db table. here iam using pagination for questions to be displayed to client
How to store an image in database
How to store an image in database  Hi........... How to store an image in postgresql using a query. I mean tell me the way to store an image using datatype. I am using the datatype bytea but tell me how to insert the image
store and retrive image from the database
to store and retreive images from sql database using sql commands -how to store and retreive images from sql database using asp.net/c# thanks in advance...store and retrive image from the database  please provide me
Store XML file into Sqlserver Database
Store XML file into Sqlserver Database  Code for storing a typical XML file into SQl server database in 1 or more tables using asp.net using C
database spring registration form
database spring registration form We are going to discuss about  database... with many fields. Here we can store all data in database. We then create jsp registration form. We have used controller and we are using database
store values of drop down list box in database
store values of drop down list box in database  how to store values of drop down list box in oracle database in jsp?I have information inserting form where i have date of birth as drop down list box
How to store JComboBox item into database
How to store JComboBox item into database   import java.sql.Connection; import java.sql.DriverManager; import java.sql.Statement; import...(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); setTitle("DETAIL FORM
store dropdown box values in database server
store dropdown box values in database server  how to store dropdown box values in database server in jsp
Store XML file into Sqlserver Database
Store XML file into Sqlserver Database  Code for storing a typical XML file into SQl server database in 1 or more tables using asp.net using C#. <?xml version="1.0" ?> <!DOCTYPE PubmedArticleSet (View Source
Write a program to get student details and store in a database
Write a program to get student details and store in a database  Write a program to get student details and store in a database
store dynamic generated textbox value into database
store dynamic generated textbox value into database  sir, how do i store dynamically generated textbox value into the database thanks in advance
Jsp Code to store date in database - JSP-Servlet
Jsp Code to store date in database   Hi, Can u give me jsp code to store current date in to database. Thanks Prakash
how to store and then immediately retrieve when store the image into database?
how to store and then immediately retrieve when store the image into database?  how to store and then immediately retrieve when store the image into database?   Here is a jsp code that insert and retrieve image from
store & retrive the image from oracle database
store & retrive the image from oracle database  how can i store the image path in tha database & fetch that image from oracle database
Store values of dynamically generated textboxes into database
Store values of dynamically generated textboxes into database   I'm trying to create a form where the user gives number to generate textboxes. when... it to be saved in MYSQL database. Anybody please help me
check box realtive information in page store in database
in page store in database plz help me...check box realtive information in page store in database  check box relative information in page store in database  hiiiiiiiii, Que I
retrieve data from mysql database and store it in a variable ?
retrieve data from mysql database and store it in a variable ?  sir... to store that data in int variable. how to do this ?   Here is an example that retrieve the integer values from the database and stored in the integer
store and retrive image from database - JDBC
store and retrive image from database  how to store and retrive an image in database using java?  Hi friend, Code for store image in database using Java. import java.sql.*; import java.io.*; public class
how to store image upload path to mssql database
how to store image upload path to mssql database  hi there!!, i need help in storing the image upload path into the database. basically i just use file select to upload the image from jsp to database. however when i click submit
how to store image upload path to mssql database
how to store image upload path to mssql database  hi there!!, i need help in storing the image upload path into the database. basically i just use file select to upload the image from jsp to database. however when i click submit
how to store image upload path to mssql database
how to store image upload path to mssql database  hi there!!, i need help in storing the image upload path into the database. basically i just use file select to upload the image from jsp to database. however when i click submit
how to store image upload path to mssql database
how to store image upload path to mssql database  hi there!!, i need help in storing the image upload path into the database. basically i just use file select to upload the image from jsp to database. however when i click submit
store current system date in to database - Development process
store current system date in to database  Hi,this is my code . here iwant to store current system date in to database and want to store subdept..."); function change(combo1){ var comboValue = combo1.value; document.forms["form
Advertisements
 

 

 

DMCA.com