1 / 3

JAVA Connection

JAVA Connection The following uses a ‘bridge’ between Java Database Connectivity (JDBC) and ODBC, namely sun.jdbc.odbc.JdbcOdbcDriver Supplied with the JAVA SDK. ‘ Aspdatatest ’ is a system DSN which contains connection information for the database. import java.sql.*;

keelty
Download Presentation

JAVA Connection

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. JAVA Connection The following uses a ‘bridge’ between Java Database Connectivity (JDBC) and ODBC, namely sun.jdbc.odbc.JdbcOdbcDriver Supplied with the JAVA SDK. ‘Aspdatatest’ is a system DSN which contains connection information for the database.

  2. import java.sql.*; public class CreateCoffees { public static void main(String args[]) { String url = "jdbc:odbc:aspdatatest"; Connection con; String createString; createString = "create table COFFEES " + "(COF_NAME VARCHAR(32), " + "SUP_ID INTEGER, " + "PRICE FLOAT, " + "SALES INTEGER, " + "TOTAL INTEGER)"; Statement stmt; try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); } catch(java.lang.ClassNotFoundException e) { System.err.print("ClassNotFoundException: "); System.err.println(e.getMessage()); }

  3. try { con = DriverManager.getConnection(url, "u0000667", "rspb"); stmt = con.createStatement(); stmt.executeUpdate(createString); stmt.close(); con.close(); } catch(SQLException ex) { System.err.println("SQLException: " + ex.getMessage()); } }}

More Related