A database operation problems

Category: Java EE
2011-10-09 09:29:10

Sponsored Links
I would like to insert a row in a database record, because I do not know in advance the number of records, so this row stored in a vector, the database in each column attributes are of type double
I use the following program segment generation Insert query:
tablename is the name of the table to operate, inputField records are stored vector, because you want to insert the user input, so the vector is stored in a series of JTextfield, the question now is to generate insert statement item value is string type, while the database needs to double type, how to solve it? Please expert guidance, thank you!

String sqlurl = "inset into" + tableName + "values ​​(";
for (int i = 0; i <inputField.size () -1; i + +) {
sqlurl + = ((JTextField) (inputField.elementAt (i))). getText ();
sqlurl + = ",";
sqlurl + = (((JTextField) inputField.elementAt (inputField.size () -1)). getText ());
sqlurl + = ")";
/ / System.out.println (sqlurl);
stm.execute (sqlurl);

Sponsored Links

2011-10-09 09:46:25
2011-10-09 09:59:18
I thought nothing of it
As long as you do not lose accuracy if
the String is possible
Domain and server ip had changed since 8/23/2013. Suspend the user registration and posts for program maintenance.