DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 2 of 2
  1. #1
    Tha'er Guest

    JDBC with MS-Access


    Anybody know how to do JDBC with MS Access. i need to know how to establish
    a connection..thnx

  2. #2
    a albert77 Guest

    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(
    "jdbcdbc: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();
    }

    }



Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


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


Sponsored Links