Oracle JDBC error

P

Peter Ashford

I'm getting this error doing an SQL insert:

java.sql.SQLException: ORA-01745: invalid host/bind variable name

I know there's no invalid names in the insert because I can insert
data into the table by hand over sqlplus.

I'm using oracle's ojbdc14 jdbc driver and Java 1.6.

Any ideas?
 
G

garlington

I'm getting this error doing an SQL insert:

java.sql.SQLException: ORA-01745: invalid host/bind variable name

I know there's no invalid names in the insert because I can insert
data into the table by hand over sqlplus.

I'm using oracle's ojbdc14 jdbc driver and Java 1.6.

Any ideas?

What does your insert statement look like? The actual code will help.
 
P

Peter Ashford

What does your insert statement look like? The actual code will help.

This is how I make the statement in Java:

PreparedStatement pStmt = db.prepareStatement(
"INSERT INTO departments ("+
" deptName, schoolName, division, dean, AVC, HOD,
admin, adminPhone, adminEmail," +
" streetAddress, city, cbCostCentre,
cbOHAccountCode, cbOHDisection, comments, " +
" schoolLiasonAdmin, dateEntered)" +
" VALUES (?,?,?,?,?,?,?,?,?,?"+
" ?,?,?,?,?,?,?)");

Doing the same insert in sqlplus using 'test' for all the varchars and
a dummy numbers and dates for all the other fields works fine.

I'm wondering if it's something to do with the JDBC driver, thou I've
checked and I definitely have the right versus for my version of
Oracle.
 
L

Lee Fesperman

Peter said:
This is how I make the statement in Java:

PreparedStatement pStmt = db.prepareStatement(
"INSERT INTO departments ("+
" deptName, schoolName, division, dean, AVC, HOD,
admin, adminPhone, adminEmail," +
" streetAddress, city, cbCostCentre,
cbOHAccountCode, cbOHDisection, comments, " +
" schoolLiasonAdmin, dateEntered)" +
" VALUES (?,?,?,?,?,?,?,?,?,?"+
" ?,?,?,?,?,?,?)");

You're missing a comma (,) between the 10th and 11th question mark (?)
in the VALUES list.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top