Quantcast
Channel: MySQL Forums - Connector/J, JDBC and Java
Viewing all articles
Browse latest Browse all 884

problem in inserting using dynamic approach (3 replies)

$
0
0
hello to every1

i have created a table 'stu' in mysql having 4 columns namely 'rno (int)' , 'name (char)', 'city (char)', 'phn (int)'

now i want to insert entries into dis table using java jdbc and with dynamic approach, so i used the commands after loading mysql driver and making appropriate connection:

{
Statement st=cn.createStatement();

int x=st.executeUpdate("insert into stu (rno,name,city,phn) values (" + args[0] + args[1] + args[2] + args[3] + ")");

System.out.println(x);
}

it is compiling successfully but at the tym of running it, i used dis command:

java Main 10 abcd wxyz 1234

where Main is the class containing void main() method and args is command line arguments, but it is showing an error:

"invalid sql column count doesn't match value count at row 1"

plz help
thanx in advance

Viewing all articles
Browse latest Browse all 884

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>