Results 1 to 2 of 2
Thread: jdbc problem!!! pls help
- 01-17-2010, 02:20 AM #1
Member
- Join Date
- Jan 2010
- Posts
- 11
- Rep Power
- 0
jdbc problem!!! pls help
Well this is the code i m working on... the commented statement work perfectly.. but i want the prepared statement to work..
unfortunately prepared statement doesn't work..
what am i doing wrong?
once again! if i comment the prepared statement and uncomment the commented statement code fragments that does work..
public void register(String username,String firstName,String lastName,String password) throws SQLException{
String query = "insert into user(username, first_name, last_name, password) values(?, ?, ?, ?)";
// i tried this too.. String query = "insert into user values(?, ?, ?, ?)";
PreparedStatement pstmt = conn.prepareStatement(query);
pstmt.clearParameters();
pstmt.setString(1,username);
pstmt.setString(2,firstName);
pstmt.setString(3,lastName);
pstmt.setString(4,password);
pstmt.executeUpdate();
// the following works perfectly
/* Statement statement = conn.createStatement();
statement.executeUpdate("INSERT INTO user VALUES ( username,'mark','laws','mark123');") ;*/
}
- 04-14-2010, 02:16 PM #2
Member
- Join Date
- Apr 2010
- Posts
- 2
- Rep Power
- 0
Similar Threads
-
jdbc problem!!! pls help
By dilanka007 in forum New To JavaReplies: 5Last Post: 01-16-2010, 06:07 PM -
problem with jdbc in jsp
By nishant.4545 in forum JavaServer Pages (JSP) and JSTLReplies: 3Last Post: 08-29-2009, 02:31 PM -
Problem in JDBC
By Preethi in forum New To JavaReplies: 11Last Post: 01-08-2009, 06:18 PM -
Jdbc problem
By abhiN in forum JDBCReplies: 1Last Post: 03-21-2008, 06:10 AM -
JDBC problem
By peiceonly in forum Threads and SynchronizationReplies: 2Last Post: 08-03-2007, 02:42 PM
Bookmarks