//package Answer;
import java.sql.*;
class Answercheck
{
public static String correct;
public static String user="Brandon";
/*
public static void check(int q1)
{
String dataSourceName = "questions";
String dbURL = "jdbc:odbc:" + dataSourceName;
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection(dbURL, "","");
Statement s = con.createStatement();
s.execute("SELECT copt FROM Ques WHERE ID=" +q1);
ResultSet rs = s.getResultSet();
if (rs != null) // if rs == null, then there is no ResultSet to view
while ( rs.next() ) // this will step through our data row-by-row
{
correct = rs.getString("copt");
//System.out.println("CORRECT OPTION by Answercheck"+correct + "\n");
} //while loop ends
} //try block
catch (Exception err)
{
System.out.println( "Error: " + err );
}
} // function ends
*/
public static void res(int m1)
{
String dataSourceName = "questions";
String dbURL = "jdbc:odbc:" + dataSourceName;
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection(dbURL, "","");
Statement s = con.createStatement();
s.executeUpdate("INSERT INTO Final " +"(candidate, marks) "+" VALUES "+"(' "+ user +" ' , ' " +m1 +" ' )");
//ResultSet ps = s.getResultSet();
System.out.println("Is it done??");
}
catch (Exception err)
{
System.out.println( "Error: " + err );
}
} // function ends
public static void main(String x[])
{
//check(1);
res(4);
}
} //class ends
have a look at the Insert sql command....
It runs perfectly...But it wont insert the values into the Database... Ive checked the Database...its allright...but no value is inserted into it
what am i dong wrong?