aspose file tools*
The moose likes JDBC and the fly likes java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Too few parameters Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Too few parameters " Watch "java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Too few parameters " New topic
Author

java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Too few parameters

mansi gandhi
Greenhorn

Joined: Apr 12, 2008
Posts: 3
import java.sql.*;
import java.sql.Connection;
import java.sql.Statement;
import java.sql.ResultSet;


public class DBConnectie{

String DBName, DBUser, DBPass, SQLQuery;
Connection conn;
Statement stmt;
ResultSet result;
String parent1;
String storyname;
String parent2;
String parent3;
String target;
String event;
String str;
String path;

public DBConnectie(String DBName,String DBuser , String DBPass)
{
this.DBName = DBName;
this.DBUser = DBUser;
this.DBPass = DBPass;
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}

catch(Exception e)
{
System.err.println(e);

}
}



public void connect()
{
try {
conn=DriverManager.getConnection("jdbcdbc:eventdata");
//conn = DriverManager.getConnection("jdbc:mysql://localhost/" + DBName + "?user=" + DBUser + "&password=" + DBPass);
}catch(Exception e){System.out.println(e + "HELLOOOO");}
}

public ResultSet selectQuery(String SQLQuery)
{
this.SQLQuery = SQLQuery;

try {
stmt = conn.createStatement();
result = stmt.executeQuery( "SELECT"+" name"+"password"+ "FROM online" );
}
catch( Exception e ){System.err.println(e+"catch 2345");}
return result;
}

public void query(String SQLQuery)
{
this.SQLQuery = SQLQuery;
try {
stmt = conn.createStatement();
stmt.executeQuery( "SELECT storyname,parent1,parent2,parent3,target,event,story FROM data");
}catch( Exception e ){System.err.println(e+"mansi");}
}

public void close()
{
try {
stmt.close();
conn.close();
}
catch(Exception e){System.err.println(e+"hi");}
}
}

this is my code and im getting the above show error plzz help i hav checked the data base
my database is in MS ACCESS.all tables are proper i need urgent help
Muhammad Saifuddin
Ranch Hand

Joined: Dec 06, 2005
Posts: 1321

Hi Mansi,

Welcome to Javaranch.

Originally posted by mansi gandhi:
i need urgent help


I would like to refer some reading about..How To Ask Questions On JavaRanch and regarding your urgent help -> Ease Up


Saifuddin..
[Blog][Linkedin] How To Ask Questions On JavaRanch My OpenSource
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42950
    
  70
result = stmt.executeQuery( "SELECT"+" name"+"password"+ "FROM online" );

I doubt that this line does anything useful. Have you checked the query that you're sending to the DB (maybe by printing it to the console)?
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

You haven't indicated which line throws the Exception, but I'm guessing this one:


Take out the obfuscation and you get the following:



The database thinks you are refering to a parameter, which has not been specified. I believe you mean to say:

David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

d'oh
mansi gandhi
Greenhorn

Joined: Apr 12, 2008
Posts: 3
try {
stmt = conn.createStatement();
stmt.executeQuery( "SELECT storyname,parent1,parent2,parent3,target,event,story FROM data");
}catch( Exception e ){System.err.println(e+"mansi");}
}
this part of my code is giving exception
mansi gandhi
Greenhorn

Joined: Apr 12, 2008
Posts: 3
i have tried what you told me to but still I'm getting the same error..
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

Originally posted by mansi gandhi:
SELECT storyname,parent1,parent2,parent3,target,event,story FROM data


Check each of these table attributes and make sure the spelling is the same as the in the database
Muhammad Saifuddin
Ranch Hand

Joined: Dec 06, 2005
Posts: 1321

or check your attribute in your data table, does all of these attribute are exist.
Jhakda Velu
Ranch Hand

Joined: Feb 26, 2008
Posts: 166
Hi
I don't think "Too few Parameters" exception would be thrown for a simple select statement like yours. Can you post the full error stack trace? This will enable folks to narrow down to the problem faster.
Are you sure that you are able to connect to the DB?
Jhakda


If I become filthy rich, I'll sponsor research for painless dental treatment at Harvard Medical School. Thats why,I'm learning Java.I have 32 teeth, 22 are man made.
 
 
subject: java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Too few parameters