Hello! There is another problem which I am facing in JDBC, is Insert statement. I am giving code of my program and explaining my problem . I am using ms access and netbeans 8.1

package database2;
import java.sql.*;


public class Database2 {

    public static void main(String[] args) {


  try
        {
          Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
          String url = "jdbc:odbc:personDSN";

         // making a query string  
           String sql = "INSERT INTO students (rollno, name, program           )VALUES(25, 'Hussain', 'Mcs')";

        Connection connection = DriverManager.getConnection(url);
          Statement st = connection.createStatement();


     System.out.println("Table of Students");

      System.out.println("Updations: "+ count);

      st.close();

        connection.close();
        }

        catch(ClassNotFoundException|SQLException sqlEx)
        {
           System.out.println(sqlEx);  
        }

  }

as you can see in start of program there is a String sql , in which I have put a sql query. When I run this program then following exception occurs:
java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] The INSERT INTO statement contains the following unknown field name: 'rollno'. Make sure you have typed the name correctly, and try the operation again."

I have checked that the attributes in my database table are same as I have passed in query, but i dont now that why is this exception occures. Please guide me.

To tell you more I would have to see a copy of the definition of the students table (i.e. field list) but basically the system is telling you it does not see a field by that name under students. Your not getting a database not found or table not found error so double check the field name.

This looks similar to the problem you posted a week ago (column names not recognised). I see that you have not yet marked that one "solved". Maybe you should fix your first column name problem before trying to move on to this one.

In any case, posting the wrong code is a horrible waste of everyone's time. The code posted makes no sense.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.