• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Too few Parameter....

B

Bretenn

Guest
#1
actualli wat does this too few parameters mean??

everytime when i try to login into the java program that my fren borrowed to me, after i login, that word will prompt out..... ..... too few parameter. Expected 2

but the prob is the database is empty. so when i add some data,
it will be diffrent. now that will prompt out.... too few parameter. expected 1.

what can i really do or modify to make my program work.... i'm a newbie so i really needs some help....
 

Khayman

I'm sorry Hal...
Political User
#2
sometimes programs require arguments (extra information) in order to start properly. the program expect 2 additional arguments, and not knowing anything about the program they could be anything. could be a file name or just some switches
it would be something like this

<your program> <argument one> <argument two>
 
B

Bretenn

Guest
#3
java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 1.
at sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:6031)
at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:6188)
at sun.jdbc.odbc.JdbcOdbc.SQLExecDirect(JdbcOdbc.java:2494)
at sun.jdbc.odbc.JdbcOdbcStatement.execute(JdbcOdbcStatement.java:334)
at sun.jdbc.odbc.JdbcOdbcStatement.executeQuery(JdbcOdbcStatement.java:249)
at entity.university.Intake.getCourseData(Intake.java:118)
at entity.university.Intake.<init>(Intake.java:26)
at entity.people.Student.<init>(Student.java:29)
at entity.university.University.getStudentData(University.java:363)
at entity.university.University.startConnection(University.java:300)
at entity.university.University.<init>(University.java:33)
at entity.university.University.<clinit>(University.java:17)
at Main.main(Main.java:17)
Exit code: 1
There were errors

following is the code for intake.java
please guys see what is the error ok 10q.....
 
B

Bretenn

Guest
#4
public class Intake{
private String intakeID;
private String studyProgram;
private ArrayList course = new ArrayList();
public Intake(){
}

public Intake(String intakeID,String studentID){
this.intakeID = intakeID;
getIntakeData();
getCourseData(studentID);

}

public String getIntakeID(){
return intakeID;
}

public String getStudyProgram(){
return studyProgram;
}

public Course getCourse(int value){
return (Course)course.get(value);
}

public Iterator getAllCourse(){
return course.iterator();
}

public int getCourseAmount(){
return course.size();
}

public void setStudyProgram(String sp){
studyProgram = sp;
}

public boolean addCourse(Course newCourse){
if (!course.contains(newCourse)){
course.add(newCourse);
return true;
}
else return false;
}

public boolean delCourse(Course delCourse){
if (course.contains(delCourse)){
course.remove(delCourse);
return true;
}
else return false;
}

public void delCourse(){
course.removeAll(course);
}

private void getIntakeData(){
try {
String url = "jdbc:eek:dbc:eek:op";
String user = "oop";
String password = "abc123";
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection connection = DriverManager.getConnection(url,user,password);
System.out.println("Connection Successful");
Statement statement = connection.createStatement();
String query = "SELECT * FROM Intake WHERE intakeid ='" + intakeID + "'";
ResultSet rs = statement.executeQuery(query);
if (rs.next()){
studyProgram = rs.getString("studyprogram");
}
}
catch (ClassNotFoundException cnfex) {
cnfex.printStackTrace();
JOptionPane.showMessageDialog(null,"Database Connection Error",
"World Virtual University",JOptionPane.ERROR_MESSAGE );
System.exit(1);
}
catch (SQLException sqlex) {
sqlex.printStackTrace();
JOptionPane.showMessageDialog(null,"Database Connection Error",
"World Virtual University",JOptionPane.ERROR_MESSAGE );
System.exit(1);
}
catch (Exception ex) {
ex.printStackTrace();
JOptionPane.showMessageDialog(null,"Database Connection Error",
"World Virtual University",JOptionPane.ERROR_MESSAGE );
System.exit(1);
}
}

private void getCourseData(String studentID){
try {
String url = "jdbc:eek:dbc:eek:op";
String user = "oop";
String password = "abc123";
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection connection = DriverManager.getConnection(url,user,password);
Statement statement = connection.createStatement();
String query = "SELECT * FROM Course WHERE intakeid ='" + intakeID + "'";
ResultSet rs = statement.executeQuery(query);
if (rs.next()){
do{
String a = rs.getString("courseid").trim();
String b = rs.getString("coursename").trim();
String d = rs.getString("lecturerid");
course.add(new Course(a,b,d,intakeID,studentID));
}while(rs.next());
}
}
catch (ClassNotFoundException cnfex) {
cnfex.printStackTrace();
JOptionPane.showMessageDialog(null,"Database Connection Error",
"World Virtual University",JOptionPane.ERROR_MESSAGE );
System.exit(1);
}
catch (SQLException sqlex) {
sqlex.printStackTrace();
JOptionPane.showMessageDialog(null,"Database Connection Error",
"World Virtual University",JOptionPane.ERROR_MESSAGE );
System.exit(1);
}
catch (Exception ex) {
ex.printStackTrace();
JOptionPane.showMessageDialog(null,"Database Connection Error",
"World Virtual University",JOptionPane.ERROR_MESSAGE );
System.exit(1);
}

}
}
 
B

Bretenn

Guest
#6
anyone of u can help to see my program?? it's a 2~3mb....
i really dun hav any idea oredi..... realli stuck!!! thanks in advance
 
#7
One thing’s for sure this is an error produced by an “SQL” text string (paramitised) that runs after you have attempted to log on. The query, which is probably a text string, held in a variable, has been instructed to look for two parameters, which together form the correct syntax for the SQL query to execute without error. They can be declared parameters (which usually require two entries in two pop-up data boxes) or just simple variables where the programmer has not taken into account all possibilities.

This is a bad-programming error especially when using “pass through” queries, or just simply an error in the writing of the code as if any of the parameters are null or equate to empty strings (where this has not been previously taken into account) then this error is generated. Incorrect spelling can also give this error.

This error is also generated if the base tables field (that is to be updated) has been set to [Field].required (property set to true) yet in the update or append query it’s attempting to set it so something else like nothing. This is a common error where the number of fields to be updated or accessed does not equal the number in the base table/s or declared SQL pass through query. It will still compile without error, just wont run properly.

Return the application to the source and ask them to check their SQL syntax for errors.

You would be better off using MS Access it quicker to develop a a whole lot easier to de-bug and then converting it to whatever you want.
 
I

Informant

Guest
#8
It looks a call is being made to get data and it missing a valid Student id. I would make sure that that parameter is getting passed in right.
 

Members online

No members online now.

Latest posts

Latest profile posts

Hello, is there anybody in there? Just nod if you can hear me ...
Xie
What a long strange trip it's been. =)

Forum statistics

Threads
61,961
Messages
673,239
Members
89,016
Latest member
ernestrojasn