Hi all, I am trying to add a new row into my table, in which the name depends on the String variable "InstrumentName". The values are listed in order and I'm pretty sure I haven't missed a column. Though when I try to run it, it says I have "too few parameters". What's more confusing is that the lines where my errors are occuring are in blank lines.
Here is where I think where my coding is wrong:
//starts up the connection between Java and MSAccess Class.forName ("sun.jdbc.odbc.JdbcOdbcDriver"); String database = "jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=Instrumental.mdb;"; Connection conn = DriverManager.getConnection(database, "", ""); Statement s = conn.createStatement(); //generates a barcode for the new instrument String barcode = generateBarcode(section, instrumentName, ID); //converting int-ID into a string-ID String stringID = "" + ID; System.out.println (barcode); System.out.println (stringID); //adding a new for the new instrument String addRow = "INSERT INTO " + instrumentName + " VALUES (" + stringID + "," + company + "," + model + "," + serial + "," + barcode + "," + "''" + "," + "''" + ")"; System.out.println (addRow); s.execute(addRow); s.close(); conn.close();
Here is the full error message:
Am I missing something in my code? If I am, I can't quite seem to catch it. Please help and I thank you in advance!HTML Code:[exception]java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 2. at sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:6957) at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:7114) at sun.jdbc.odbc.JdbcOdbc.SQLExecDirect(JdbcOdbc.java:3110) at sun.jdbc.odbc.JdbcOdbcStatement.execute(JdbcOdbcStatement.java:338) at VersionTwo.AddInstrument(VersionTwo.java:70) at VersionTwo.main(VersionTwo.java:45) at __SHELL7.run(__SHELL7.java:6) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at bluej.runtime.ExecServer$3.run(ExecServer.java:724[/exception]