473,387 Members | 1,742 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

JSP with JDBC

58
How do you get the values from the controls in a JSP page to the code in JDBC so that it can be stored in MySql database?
Sep 25 '07 #1
6 1796
jith87
58
What command will you use to get the values from controls (for eg.... text box, check box, list box) in a JSP page to the JDBC code so that they can be stored in MySql database?
Sep 25 '07 #2
dmjpro
2,476 2GB
What command will you use to get the values from controls (for eg.... text box, check box, list box) in a JSP page to the JDBC code so that they can be stored in MySql database?
Have a look at this code.
Expand|Select|Wrap|Line Numbers
  1. void storeValueIntoDatabase(HttpServletRequest request)
  2. {
  3.  String value1 = request.getParameter("control1");
  4.  .
  5.  .
  6.  String value_n = request.getParameter("control_n");
  7.  String database_url = ""; //your database url
  8.  String insert_query = ""; //your insert query
  9.  Class.forName("driver_class");
  10.  Connection con = DriverManager.getConnection(database_url,"user_name","password");
  11.  Statement st = con.createStatement();
  12.  st.executeUpdate(insert_query);
  13.  con.commit();
  14. }
  15.  
Good Luck :-)

Kind regards,
Dmjpro.
Sep 25 '07 #3
JosAH
11,448 Expert 8TB
How do you get the values from the controls in a JSP page to the code in JDBC so that it can be stored in MySql database?
You should've asked your question in the Java Forum section, not in the Java
Articles section. I'll move your question for you.

kind regards,

Jos
Sep 25 '07 #4
jith87
58
Have a look at this code.
Expand|Select|Wrap|Line Numbers
  1. void storeValueIntoDatabase(HttpServletRequest request)
  2. {
  3.  String value1 = request.getParameter("control1");
  4.  .
  5.  .
  6.  String value_n = request.getParameter("control_n");
  7.  String database_url = ""; //your database url
  8.  String insert_query = ""; //your insert query
  9.  Class.forName("driver_class");
  10.  Connection con = DriverManager.getConnection(database_url,"user_name","password");
  11.  Statement st = con.createStatement();
  12.  st.executeUpdate(insert_query);
  13.  con.commit();
  14. }
  15.  
Good Luck :-)

Kind regards,
Dmjpro.
Thanx....I understood it.. What i want to know now is "Is the same function being used for all the controls?"
Sep 25 '07 #5
r035198x
13,262 8TB
Thanx....I understood it.. What i want to know now is "Is the same function being used for all the controls?"
For array types you use getParameterValues.
Which control do you want specifically?
Sep 25 '07 #6
dmjpro
2,476 2GB
Thanx....I understood it.. What i want to know now is "Is the same function being used for all the controls?"
Have a look at this.

Expand|Select|Wrap|Line Numbers
  1. <input value = "some_value1" name = "same_name">
  2. <input value = "some_value2" name = "same_name">
  3. <input value = "another_value" name = "another_name">
  4.  
Expand|Select|Wrap|Line Numbers
  1. String value1 = request.getParameter("same_name");
  2. //it will retrieve first one, means some_value1
  3. String value2[] = request.getParameterValues("same_name");
  4. //it will retrieve the array of values
  5.  
So you can call both for any, means for single named control or multiple named controls. It does not matter.

Kind regards,
Dmjpro.
Sep 25 '07 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: JShurmatz | last post by:
If anyone can shed some light on this problem I would greatly appreciate it. I am unsuccessfully trying to use a database connnection retrieved from a pool configured using Java System Web...
0
by: Nils Valentin | last post by:
Hi MySQL Fans ;-), Is it possible that the 3.08 series allows to connect to 4.0.14 versions but not to the 4.1 alpha-versions ? I get belows error when tryig to connect from DbVisualizer which...
0
by: Robert Mazur | last post by:
MySQL 5.0 alpha (binary install) on Solaris 9 -or- RedHat 8.0 mysql-connector-java-3.0.8-stable ----------------------- Is there something different going on with JDBC and the alpha version...
0
by: Bing | last post by:
Hi, I am configuring the same DB2 v8.1 JDBC universal driver (db2jcc.jar and db2jcc_license_cisuz.jar) from DB2 SP5 fix pack under WSAD 5.1.x environment and WebSphere application Server 5.0.2...
0
by: Raquel | last post by:
UDB PE 8.1 on Win XP. Per the manual: DB2 JDBC traces always begin with a header that lists important system information such as key environment variable settings, the JDK or JRE level, the...
1
by: Praveen | last post by:
Hi, I have installed WebSphere Portal on AIX and connected to DB2 on a remote machine, Getting the followin errors when trying to get the values from database thru applications installed on...
1
by: rpm45tech | last post by:
Hi everyone. I'm deveolping in Java with DB2 running on Win XP and everything was working ok but then I installed Vista Ultimate and the application stopped working. This is the exception showed: ...
2
by: bevis | last post by:
I'm new to sql server and mysql but this seems like it should be a pretty straight forward jdbc connection. But I have spent almost 2 days just trying to get a jdbc connection. Please help if you...
3
by: Anoop | last post by:
Is it true that there are no type 4 jdbc drivers to connect to a DB2 server v7.1? The DB2 server is hosted on ACF2 (OS/390). We would be connecting from windows and solaris boxes. If it is true,...
0
by: Jim Kennedy | last post by:
ALL DDL does a commit. Hence Drop Table movies; issues a commit. True you don't issue a commit and the driver does not issue a commit, but the server does for all DDL. That is probably where...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.