| | |
SQL Insert - which method to use
Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved |
•
•
Join Date: Mar 2008
Posts: 42
Reputation:
Solved Threads: 0
Hi there!
I'm building a small application using Java and MySQL (college assignment).
Everything is ok when all I'm doing are queries using SELECT.
Now, when I try to INSERT anything in the table, I get this error message:
java.sql.SQLException: Can not issue data manipulation statements with executeQuery(). 0 S1009
Ok, so I should use something else other than executeQuery to manipulate data (and I suppose the same will happen if I try to UPDATE the table as well).
So, please, what should I use? I tried other methods from NetBeans but did not quite understand how to use them.
This is the code I'm using:
Thanks!!
I'm building a small application using Java and MySQL (college assignment).
Everything is ok when all I'm doing are queries using SELECT.
Now, when I try to INSERT anything in the table, I get this error message:
java.sql.SQLException: Can not issue data manipulation statements with executeQuery(). 0 S1009
Ok, so I should use something else other than executeQuery to manipulate data (and I suppose the same will happen if I try to UPDATE the table as well).
So, please, what should I use? I tried other methods from NetBeans but did not quite understand how to use them.
This is the code I'm using:
Java Syntax (Toggle Plain Text)
Statement statement=conn.createStatement(); ResultSet resultSet=statement.executeQuery(sqlstring);
Thanks!!
executeUpdate not executeQuery (on non-select queries)
Java Programmer and Sun Systems Administrator
----------------------------------------------
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
----------------------------------------------
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
![]() |
Similar Threads
- insert csv file into mysql through php (PHP)
- SQL Help (MySQL)
- Problems with INSERT INTO and ADO (Visual Basic 4 / 5 / 6)
- retrieving a particular value with a sql query (PHP)
- sql statement (Visual Basic 4 / 5 / 6)
- SQL Query inserts junk data as well (ASP)
- $rs=mysql_query($sql) or die("error in common.inc.php at line 257"); (PHP)
- msql data transer problems (MySQL)
- how do i display updated records from database (Java)
- I need help with a parse error! (PHP)
Other Threads in the Java Forum
- Previous Thread: Creating PCB designing software
- Next Thread: Need help with the java code!
| Thread Tools | Search this Thread |
911 actionlistener addressbook android api append applet application array arrays automation binary block bluetooth character chat class client code component consumer csv database desktop eclipse error fractal ftp game givemetehcodez graphics gui html ide image input integer j2me japplet java javaarraylist javac javaee javaprojects jmf jni jpanel julia linked linux list loop mac map method methods mobile netbeans newbie number objects online oriented panel print printf problem program programming project projects properties recursion replaydirector reporting researchinmotion rotatetext rsa scanner screen se server set size sms sort sql string swing template test threads time title tree tutorial-sample ubuntu update windows working






