This week's book giveaway is in the HTML Pages with CSS and JavaScript forum.
We're giving away four copies of Testing JavaScript Applications and have Lucas da Costa on-line!
See this thread for details.
Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

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

 
Ranch Hand
Posts: 168
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 2908
1
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please use CodeTags

And problem is in this line:

Are you sure that "name" value is being pass to the statement ?
 
Consider Paul's rocket mass heater.
    Bookmark Topic Watch Topic
  • New Topic