systech44
Oct 14th, 2009, 05:41 AM
Hello,
I have a problem. I am trying to access and display the data available in the MS Access. Please check the code and rectify.
import java.sql.*;
public class Test
{
public static void main(String ags[])
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection conn = DriverManager.getConnection("jdbc:odbc:test","","");
Statement st = conn.createStatement();
ResultSet rs = st.executeQuery("select * from test");
while(rs.next())
{
int id = rs.getInt(1);
String name = rs.getString(2);
System.out.println(id + " " + name);
System.out.println("<br/>");
}
}
catch(Exception e)
{
System.out.println("Error");
}
}
}
Thanks & Regards.
I have a problem. I am trying to access and display the data available in the MS Access. Please check the code and rectify.
import java.sql.*;
public class Test
{
public static void main(String ags[])
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection conn = DriverManager.getConnection("jdbc:odbc:test","","");
Statement st = conn.createStatement();
ResultSet rs = st.executeQuery("select * from test");
while(rs.next())
{
int id = rs.getInt(1);
String name = rs.getString(2);
System.out.println(id + " " + name);
System.out.println("<br/>");
}
}
catch(Exception e)
{
System.out.println("Error");
}
}
}
Thanks & Regards.