Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: Re: I need help Plz

  1. #1
    Junior Member
    Join Date
    Apr 2012
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: I need help Plz

    this is as follows my source code and run time error i got how i can solve this please inform me ASAP:

     
    import java.sql.*;
    import java.lang.*;
    public class ExcelInsertDemo
    {
    public static void main(String args[])throws ClassNotFoundException,SQLException
    {
     
    String driverclass="sun.jdbc.odbc.JdbcOdbcDriver";
    String url="jdbc:odbc:xldsn";
    String user="sa";
    String password="";
    Class.forName(driverclass);
    System.out.println("driver loaded successfully");
    Connection con=DriverManager.getConnection(url,user,password);
    /*if(con!=null)
    System.out.println("Connected to the database with the database now");
    */
    Statement st=con.createStatement();
    String sql="insert into [Sheet1$] values(12,pavan,90)";
    st.executeUpdate(sql);
    System.out.println("query executed");
    con.close();
     
    }
    }
    compilation

    C:\>javac ExcelInsertDemo.java

    C:\>java ExcelInsertDemo
    driver loaded successfully
    Exception in thread "main" java.sql.SQLException: [Microsoft][ODBC Excel Driver]
    Too few parameters. Expected 1.
    at sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc .java:6957)
    at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java :7114)
    at sun.jdbc.odbc.JdbcOdbc.SQLExecDirect(JdbcOdbc.java :3110)
    at sun.jdbc.odbc.JdbcOdbcStatement.execute(JdbcOdbcSt atement.java:338)
    at sun.jdbc.odbc.JdbcOdbcStatement.executeUpdate(Jdbc OdbcStatement.java:
    288)
    at ExcelInsertDemo.main(ExcelInsertDemo.java:20)


  2. #2
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,372
    Thanks
    184
    Thanked 836 Times in 779 Posts
    Blog Entries
    5

    Default Re: I need help Plz

    Please read the forum rules. I have moved your post to the appropriate location - hijacking someone else's post is not the best way to get the help you seek

  3. #3
    mmm.. coffee JavaPF's Avatar
    Join Date
    May 2008
    Location
    United Kingdom
    Posts
    3,336
    My Mood
    Mellow
    Thanks
    258
    Thanked 287 Times in 225 Posts
    Blog Entries
    4

    Default Re: I need help Plz

    I would test this by just simply connecting to the database first without sending a SQL query. If this works without a problem, you know where your issue lies..
    Please use [highlight=Java] code [/highlight] tags when posting your code.
    Forum Tip: Add to peoples reputation by clicking the button on their useful posts.

    Looking for a Java job? Visit - Java Programming Careers