10.07.2015 Views

JDBC Developer's Guide - Supra - Cincom

JDBC Developer's Guide - Supra - Cincom

JDBC Developer's Guide - Supra - Cincom

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

System.out.println ("Please enter information to test connection to thedatabase");String user;String password;String database;user = readEntry ("user: ");int slash_index = user.indexOf ('/');if (slash_index != -1) {password = user.substring (slash_index + 1);user = user.substring (0, slash_index);}elsepassword = readEntry ("password: ");database = readEntry ("database name: ");System.out.print ("Connecting to the database...");System.out.flush ();System.out.println ("Connecting...");Connection conn =DriverManager.getConnection("jdbc:cincomordb:" + database,user, password);System.out.println ("connected.");// Create a statementStatement stmt = conn.createStatement ();// Do the SQL "Hello World" thingResultSet rset = stmt.executeQuery ("select 'Hello World' from classdb_user");// Display Resultswhile (rset.next ())System.out.println (rset.getString (1));// close the result set, the statement and connectionrset.close();stmt.close();<strong>JDBC</strong> <strong>Developer's</strong> <strong>Guide</strong>, P25-9504-03 Page 17Chapter: 2. Verifying a <strong>JDBC</strong> Driver installationSection: Check the environment variables

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!