Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package exercises;
- import java.sql.*;
- /*
- * @author Kenton Dang
- */
- public class JDBCex1 {
- static Connection conn = null;
- static String dbURL = "jdbc:oracle:thin:@127.0.0.1:1521:XE";
- static String user = "labs";
- static String password = "labs";
- public JDBCex1() { }
- public static void main (String args[]) throws SQLException {
- try {
- Class.forName("oracle.jdbc.driver.OracleDriver");
- } catch (ClassNotFoundException e) {
- System.err.println(e.getMessage());
- }
- try {
- conn = DriverManager.getConnection(dbURL, user, password);
- conn.clearWarnings();
- System.out.println("Connection opened! For driver ==>Oracle 11XE");
- } catch (SQLException e) {
- System.err.println(e.getMessage());
- } finally {
- if (!conn.isClosed()) {
- conn.close();
- System.out.println("Connection closed! Oracle");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement