//require ojdbc6.jar in classpath
String driverName = "oracle.jdbc.driver.OracleDriver"; 
String connectionURL = "jdbc:oracle:thin:@oracledb.mstrblog.co.uk"; 
String login = "user1"; 
String password = "password1"; 
String tableName = "DELIVERY"; 
String userColumn = "DELIVERY_ID"; 
try { 
//load driver
Class.forName(driverName).newInstance(); 
//use jdbc url, database login, and database password to create connection 
java.sql.Connection conn = java.sql.DriverManager.getConnection(connectionURL, login, password); 
java.sql.Statement stmt = conn.createStatement();
//execute sql query 
String dbQuery = "SELECT " + userColumn + " FROM " + tableName; 
java.sql.ResultSet empNames = stmt.executeQuery (dbQuery); 
while (empNames.next()) { 
String name = empNames.getString(1);
//String cmQuery = "CREATE USER \"" + name + "\";";
//execute(cmQuery);
printOut("user '" + name + "' is successfully created");
} 
empNames.close(); 
stmt.close(); 
conn.close(); 
} catch (Exception e) { 
printErr(e.getMessage()); 
}

Leave a Reply

Your email address will not be published. Required fields are marked *