ORA-00913: too many values
Solution 1
This would suggest that your blobtab table didn't have two columns in it (or if there's a trigger on the table, check the DML being fired recursively in those for the same problem).
insert into blobtab values(?,?)
eg:
SQL> create table foo(id number);
Table created.
SQL> insert into foo values (1, 2);
insert into foo values (1, 2)
*
ERROR at line 1:
ORA-00913: too many values
check your table. also you should always put explicit column names on your insert (in case someone adds default or nullable columns later on. i.e. always do:
insert into blobtab (col1, col2) values(?,?)
where col1
col2
are your real column names.
Solution 2
the number of column would have been less than the paraemeter/argument passed
eg: insert into insert into foo(name , age) values (?,?,?) and then preparedStatment object insert
Since there is 2 column and value have 3 parameter therefore , ORA-00913: too many values
Ganesan S
Updated on June 14, 2022Comments
-
Ganesan S almost 2 years
getting
ORA-00913:
too many values. don't know how to resolve this issue please anyone could help me?con2 = DriverManager.getConnection("Jdbc:Oracle:thin:@localhost:1521:XE", "system", "oracle123"); File image=new File("E:/Users/ganesh/Desktop/line.jpg"); String sql="insert into blobtab values(?,?)"; pstmt=con2.prepareStatement(sql); pstmt.setString(1,"akshita"); fis=new FileInputStream(image); pstmt.setBinaryStream(2,(InputStream)fis,(int)(image.length())); int s = pstmt.executeUpdate(); if (s > 0) { System.out.println("Image Uploaded successfully !"); } else { System.out.println("unsucessfull to upload image."); } con2.close(); pstmt.close();