Code Samples

These code examples and other materials are subject to Sun Microsystems, Inc. Legal Terms

Connecting to a Database

This example uses the JDBC-ODBC bridge to connect to a database called ``mydatabase''.
 try {
   Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
  
    String url = "jdbc:odbc:mydatabase";
    Connection connection = 
      DriverManager.getConnection(
        url, "login", "password");
 } catch (ClassNotFoundException e) {
 } catch (SQLException e) {
 }
 

ExampletsTM  are Copyrighted 2000 by Addison-Wesley and Patrick Chan
and are provided as a courtesy for your educational, non-commercial use.

Order this book from Amazon

[ This page was updated: 11-Sep-2000 ]

For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's AT&T Direct Access Number first.
Sun Microsystems, Inc.
Copyright © 1995-2000 Sun Microsystems, Inc.
All Rights Reserved. Terms of Use. Privacy Policy.