Skip to content

Instantly share code, notes, and snippets.

@cx20
Created June 10, 2012 14:32
Show Gist options
  • Save cx20/2905932 to your computer and use it in GitHub Desktop.
Save cx20/2905932 to your computer and use it in GitHub Desktop.
Hello, JDBC Type4 World! (Java + JDBC Type4 + Oracle)
import java.sql.*;
class Hello {
public static void main( String[] args ) throws Exception {
Class.forName ("oracle.jdbc.driver.OracleDriver");
Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:orcl", "scott", "tiger");
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery("SELECT 'Hello, JDBC Type4 World!' AS Message FROM DUAL");
while ( rs.next() ) {
System.out.println( rs.getString(1) );
}
rs.close();
stmt.close();
conn.close();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment