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.