-
JDBC with MS-Access
Anybody know how to do JDBC with MS Access. i need to know how to establish
a connection..thnx
-
Re: JDBC with MS-Access
"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 dbc: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();
}
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks