Home arrow static arrow Java Programming [Archive] - jdbc insert
Warning: Creating default object from empty value in /www/htdocs/w008deb8/wiki/components/com_staticxt/staticxt.php on line 51
Java Programming [Archive] - jdbc insert
This topic has 5 replies on 1 page.

Posts:97
Registered: 5/26/04
jdbc insert  
Aug 3, 2004 1:30 PM



 
PreparedStatement pst =				conn.prepareStatement(					"INSERT INTO s_elrn_data VALUES (?,?,?,?,?,?,?,?,?,?,?,?)");			// Bind the column values into the PreparedStatement      			pst.setString(1, usid);.................. 


I am using this code to insert data in the table s_elrn_data. further code like pst.setString(1,usid) inserts the values for rest of the columns in the table. Now my problem is that I donot want to fill in all the columns in the table. I know the SQl for that

[code]
insert into s_elrn_data (usid, password, manager_id)
values (123, 'fghdfdg', 1700);

[/

code]

but how do i do it in java using something similar to pst.setString(usid, 1);
 

Posts:24,036
Registered: 2/3/03
Re: jdbc insert  
Aug 3, 2004 1:31 PM (reply 1 of 5)



 
Try posting again, and use the "Preview" button.
 

Posts:3,258
Registered: 00-08-28
Re: jdbc insert  
Aug 3, 2004 1:42 PM (reply 2 of 5)



 

PreparedStatement pst =conn.prepareStatement("INSERT INTO s_elrn_data  (usid, password, manager_id)" +" VALUES (?,?,?,)");pst.setString(1, usid);.............
 

Posts:3,258
Registered: 00-08-28
Re: jdbc insert  
Aug 3, 2004 1:42 PM (reply 3 of 5)



 
Hope that fixes your problem
 

Posts:54
Registered: 11/12/03
Re: jdbc insert  
Aug 4, 2004 1:59 AM (reply 4 of 5)



 
Post question again..
 

Posts:3,081
Registered: 2/15/99
Re: jdbc insert  
Aug 4, 2004 2:40 AM (reply 5 of 5)



 
You don't want to specify values for all columns? Either remove the corresponding values from the insert statement, or set the values to null (which is what happens if you don't insert values).
    // Either    stmt.setNull(1, java.sql.Types.VARCHAR);     // or    stmt.setString(1, null);
 
This topic has 5 replies on 1 page.