Anybody know how to do JDBC with MS Access. i need to know how to establish
a connection..thnx
Printable View
Anybody know how to do JDBC with MS Access. i need to know how to establish
a connection..thnx
"Tha'er" <tzayed@yahoo.com> wrote:
>
>Anybody know how to do JDBC with MS Access. i need to know how to establish
>a connection..thnx
//below is some code which i
import java.net.*;
import java.sql.*;
import java.awt.*;
import java.awt.event.*;
public class a extends Frame
{
Choice students;
Choice grades;
Connection connection;
Statement statement;
public a()
{
students = new Choice();
grades = new Choice();
setLayout(new FlowLayout());
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
connection = DriverManager.getConnection(
"jdbc:odbc:conname", "a", "password");
statement = connection.createStatement();
String SQL = "SELECT Name FROM Students";
ResultSet resultset = statement.executeQuery(SQL);
while (resultset.next())
students.addItem(resultset.getString(1));
SQL = "SELECT Grade FROM Students";
resultset = statement.executeQuery(SQL);
while (resultset.next())
grades.addItem(resultset.getString(1));
}
catch(Exception e) {}
add(students);
add(grades);
}
public static void main (String args[])
{
Frame f = new a();
f.setSize(300, 300);
f.addWindowListener(new WindowAdapter() {public void
windowClosing(WindowEvent e) {System.exit(0);}});
f.show();
}
}