This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes JDBC and the fly likes JDBC Error-->  [Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 1 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "JDBC Error-->  [Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 1" Watch "JDBC Error-->  [Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 1" New topic
Author

JDBC Error--> [Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 1

Gaurav Pavan Kumar Jain
Ranch Hand

Joined: Mar 19, 2007
Posts: 168
Please find the code of program.

import java.io.*;
import java.sql.*;

public class NewTest
{

public NewTest()
{
}


public void enter_Data()
{
Connection con=null;
try
{
// Load Driver class

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");


// Create Odbc Connection

con=DriverManager.getConnection("jdbcdbc:test","","");

// Create Statement
Statement stat=con.createStatement();

// Insert Data in database
BufferedReader bf=new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter Name:-");
String name=bf.readLine();
stat.executeUpdate("INSERT INTO jav " + "VALUES (name)");
}

catch (Exception Ex)
{
System.err.println("Error/Exception"+Ex.getMessage());
}


finally
{
try
{
if(con !=null)
{
con.close();
}
}

catch(SQLException se)
{
System.out.println("SQL Exception");
}
}
}

public static void main(String args[])
{
NewTest obj=new NewTest();
obj.enter_Data();
}
}

I am trying to insert data in database from console at run time but it genrate error---> [Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 1.

Please help me.
Sagar Rohankar
Ranch Hand

Joined: Feb 19, 2008
Posts: 2902
    
    1

Please use CodeTags

And problem is in this line:

Are you sure that "name" value is being pass to the statement ?


[LEARNING bLOG] | [Freelance Web Designer] | [and "Rohan" is part of my surname]
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: JDBC Error--> [Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 1
 
Similar Threads
Error: [Microsoft][ODBC Microsoft Access Driver] Too few parameters.
error while using sql update statement
Problem With Inserting
File Dsn Problem?
insert to database...