Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // The URL representing the ORACLE database connection string
- private static final String ORACLE_URL = "jdbc:oracle:thin:@aloe.cs.arizona.edu:1521:oracle";
- // Start with null username and password
- String username = null;
- String password = null;
- // Ensure that we got a username and password argument
- if (args.length == 2)
- {
- username = args[0];
- password = args[1];
- }
- else
- {
- System.err.println("Error reading command line arguments, expected username and password!");
- System.exit(-1);
- }
- // Load the OracleDriver
- try
- {
- Class.forName("oracle.jdbc.OracleDriver");
- }
- catch (ClassNotFoundException exception)
- {
- System.err.println("Error loading the Oracle JDBC driver!");
- System.exit(-1);
- }
- Connection dbConnection = null;
- // Connect to the DB with the connection URL, given username and password
- try
- {
- dbConnection = DriverManager.getConnection(ORACLE_URL, username, password);
- }
- catch (SQLException exception)
- {
- System.err.println("Error connecting to the Oracle database!\nError: ");
- exception.printStackTrace();
- System.exit(-1);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement