java - "Too few parameters" error, even when I enter compatible datatypes -


I am applying a test using JDK 7, Access 2007 and Microsoft Database Engine 2010. When I enter a table with Java 'real' datatype field and entering float or double through Java, it says that the [Microsoft] [ODBC Microsoft Access driver] has very little parameters Expected 1.

But if I enter straightforward numbers then it accepts. Which field type do I use?

A column defined by using DLL as " REAL Number (single) ", which corresponds with float in JDBC. Therefore, you need to set your parameter value to .setFloat () for that column, as

  String SQL = "Include the Territory Name (Realfield) values ​​(?)"; Prepared place PS = con.prepareStatement (SQL); Ps.setFloat (1, 3.14F);   

This is a complete test code that works for me:

  import java.sql *; Public class JDBCATT {Public Static Zero Main (String Algos []) {String Connection String = "JDBC: ODBC: Driver = {Microsoft Access Driver (* .mdb)};" + "DBQ = C: / Users / Public / MDBTist.MDB;"; String tagname = "zzzJavaTest"; String sql; Try (connection con = DriverManager.getConnection (connectionString)) {sql = String.format ("drop table [% s]", tableName); Try (details s = con.createStatement ()) {try {s.executeUpdate (sql); System.out.println ("old table dropped."); } Hold (eclipse e) {if (e.getMessage () ends. ("Does not exist.") {System.out.println ("The table was not present already."); } And {throw e; }}} Hold (exception e) {e.printStackTrace (System.out); System.exit (0); } Sql = String.format ("Create table [% s] (primary number in id number, number real)", tagname); Try (statement s = con.createStatement ()) {s.executeUpdate (sql); System.out.println ("New table was created."); } Hold (exception e) {e.printStackTrace (System.out); System.exit (0); } Sql = String.format ("IN [INSERT [% s] (numfield) VALUES (?)", TableName); Try (PS3 = con.prepareStatement (SQL)) {ps.setFloat (1, 3.14F); ps.executeUpdate (); System.out.println ("new line added."); } Grip (eclipse e) {E.PintstacksTrace (system out); System.exit (0); }} Hold (exception e) {e.printStackTrace (System.out); System.exit (0); }}}    

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -