G
geletine
From the earlier example i now have a new ms access data base with
Record_number as autonumber, Artist as Text, Album as Text, Price as
Currency, Release_date as Text and Style as Text
I wrote a program to search for a artist using the Record_number, but
within runtime i get the subject error "Too few parameters, Expected 2"
I presume currency is equal to Double in java.
Here is the code
import java.sql.*;
import java.io.*;
public class Car2 {
public static void main(String args[]){
Connection connection;
Statement st;
String out="";
String display="";
String RecordNumber =""; // received from user
BufferedReader stgin = new BufferedReader ( new InputStreamReader (
System.in ) );
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
connection= DriverManager.getConnection("jdbcdbc:Records","","");
st = connection.createStatement();
System.out.println("Enter record number");
RecordNumber = stgin.readLine();
PreparedStatement ps =
connection.prepareStatement(
"SELECT Arist, Album, Price, Release_Date, Style " +
"FROM albums where RecordNumber = ? ");
ps.setString(1, RecordNumber);
ResultSet rnum = ps.executeQuery();
while (rnum.next()) {
out=" : " + rnum.getString("Artist")+"\t"+
rnum.getString("Album")+"\t"+ rnum.getDouble("Price") +
"\t"+ rnum.getString("Release_Date")+"\t"+ rnum.getString("Style"); ;
display = out;
System.out.println (display);
}
}catch (Exception e) {
e.printStackTrace();
}
}
}
at runtime
Enter record number
3
java.sql.SQLException:[Microsoft][ODBC Microsoft Access Driver] Too few
parameters. Expected 2.
at sun.jdbc.odbc.jdbcodbc.createSQLException<JdbcOdbc.java:6958>
at sun.jdbc.odbc.jdbcodbc.standardError<JdbcOdbc.java:7115>
at sun.jdbc.odbc.jdbcodbc.SQLExecute<JdbcOdbc.java:3150>
at
sun.jdbc.odbc.jdbcodbcPreparedStatement.execute<JdbcOdbcPreparedStatement.java:214>
at
sun.jdbc.odbc.jdbcodbcPreparedStatementQuery.execute<JdbcOdbcPreparedStatement.java:89>
at Car2.main.<Car2.java:32>
Record_number as autonumber, Artist as Text, Album as Text, Price as
Currency, Release_date as Text and Style as Text
I wrote a program to search for a artist using the Record_number, but
within runtime i get the subject error "Too few parameters, Expected 2"
I presume currency is equal to Double in java.
Here is the code
import java.sql.*;
import java.io.*;
public class Car2 {
public static void main(String args[]){
Connection connection;
Statement st;
String out="";
String display="";
String RecordNumber =""; // received from user
BufferedReader stgin = new BufferedReader ( new InputStreamReader (
System.in ) );
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
connection= DriverManager.getConnection("jdbcdbc:Records","","");
st = connection.createStatement();
System.out.println("Enter record number");
RecordNumber = stgin.readLine();
PreparedStatement ps =
connection.prepareStatement(
"SELECT Arist, Album, Price, Release_Date, Style " +
"FROM albums where RecordNumber = ? ");
ps.setString(1, RecordNumber);
ResultSet rnum = ps.executeQuery();
while (rnum.next()) {
out=" : " + rnum.getString("Artist")+"\t"+
rnum.getString("Album")+"\t"+ rnum.getDouble("Price") +
"\t"+ rnum.getString("Release_Date")+"\t"+ rnum.getString("Style"); ;
display = out;
System.out.println (display);
}
}catch (Exception e) {
e.printStackTrace();
}
}
}
at runtime
Enter record number
3
java.sql.SQLException:[Microsoft][ODBC Microsoft Access Driver] Too few
parameters. Expected 2.
at sun.jdbc.odbc.jdbcodbc.createSQLException<JdbcOdbc.java:6958>
at sun.jdbc.odbc.jdbcodbc.standardError<JdbcOdbc.java:7115>
at sun.jdbc.odbc.jdbcodbc.SQLExecute<JdbcOdbc.java:3150>
at
sun.jdbc.odbc.jdbcodbcPreparedStatement.execute<JdbcOdbcPreparedStatement.java:214>
at
sun.jdbc.odbc.jdbcodbcPreparedStatementQuery.execute<JdbcOdbcPreparedStatement.java:89>
at Car2.main.<Car2.java:32>