*
The moose likes JDBC and the fly likes help with a exception Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Databases » JDBC
Bookmark "help with a exception" Watch "help with a exception" New topic
Author

help with a exception

ben riches
Ranch Hand

Joined: Nov 08, 2002
Posts: 126
hello i hope someone can help me please
i have this code
but i get a exception the exception says
[microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 1.
what does this mean could someone please explain please
thanks ben
p.s. my code is below
import java.sql.*;
class JD {

public static void main (String[] args) {
String data = "jdbc dbc:World Energy";
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection conn = DriverManager.getConnection(data,"","");
Statement st = conn.createStatement();
st.executeUpdate("INSERT INTO Coal (FIPS, Country, Year)" +
"VALUES (gh, 'ghia', 1991)");

conn.close();
} catch (Exception e) {
System.err.println("Got an exception! ");
System.err.println(e.getMessage());
}

}
}
Mani Ram
Ranch Hand

Joined: Mar 11, 2002
Posts: 1140
Try this
st.executeUpdate("INSERT INTO Coal (FIPS, Country, Year)" + "VALUES ('gh', 'ghia', 1991)");
(Look at the quotes around the gh).


Mani
Quaerendo Invenietis
 
GeeCON Prague 2014
 
subject: help with a exception