JDBC with MS-Access


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: JDBC with MS-Access

Hybrid View

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

    }



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


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center