i have just started with
JDBC i tried a simple program for viewing and entring
values in MS Access.....in the below code i can retrieve
the values but cannot enter .....plzzz help
import java.sql.*;
import java.awt.*;
class Net2
{
public static void main(
String ar[])
{
try {
// Step 1: Load the JDBC driver.
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
// Step 2: Establish the connection to the database.
String url = "jdbc
dbc:mayank";
Connection conn = DriverManager.getConnection(url,"","");
Statement st = conn.createStatement();
ResultSet rs ;
//these two statements does not execute durin the program
//int m;
//st.executeUpdate("insert into mayank values('NITS') ");
rs = st.executeQuery("select class from mayank ");
conn.commit();
while(rs.next())
{
//System.out.println("ass");
System.out.println(rs.getString("class"));
//System.out.println("ass");
}
}
catch (Exception e)
{
e.printStackTrace();
/*System.err.println("Got an exception! ");
System.err.println(e.getMessage());
*/
}
}
}