List of utility methods to do JDBC Oracle Connection
Connection | getConnection(String connectString) get Connection return getConnection(connectString, null, null);
|
Connection | getConnection(String dbType, String dbIp, String dbPort, String dbName, String userName, String password) get Connection String driver = getDriverName(dbType);
String url = getURL(dbType, dbIp, dbPort, dbName);
Class.forName(driver).newInstance();
return DriverManager.getConnection(url, userName, password);
|
Connection | getConnection(String ip, String serviceName, String uid, String pwd) get Connection String driver = "oracle.jdbc.driver.OracleDriver"; String url = "jdbc:oracle:thin:@" + ip + ":1521:" + serviceName; Class.forName(driver); Connection conn = DriverManager.getConnection(url, uid, pwd); return conn; |
Connection | getDatabaseConnection() get Database Connection Connection conn = null; try { conn = DriverManager.getConnection(getDbUrl(), getUser(), getPass()); } catch (SQLException e) { System.out.println("DBHelper failed to create database connection"); e.printStackTrace(); return conn; ... |
String | getDBVersion(String dbSourceName, String server, int port, String dbName, String userid, String pwd) get DB Version StringBuffer sb = new StringBuffer(); Connection mainConn = null; String driverName = getDriverName(dbSourceName); String sql = null; if (dbSourceName.equals("oracle")) { sql = "SELECT * FROM V$VERSION"; } else if (dbSourceName.equals("db2")) { sql = "SELECT service_level||'(FP'||fixpack_num||')' FROM TABLE (sysproc.env_get_inst_info()) as x"; ... |
Connection | getJDBCConn(String hostname, String port, String sid, String username, String pwd) create by David.ze 2015/07/11 Class.forName("oracle.jdbc.driver.OracleDriver"); Connection conn = null; Class.forName("oracle.jdbc.driver.OracleDriver"); String thinLink = "jdbc:oracle:thin:@" + hostname + ":" + port + ":" + sid; conn = DriverManager.getConnection(thinLink, username, pwd); return conn; |
Connection | getJDBCConnection() get JDBC Connection try { Connection conn = null; Class.forName("oracle.jdbc.driver.OracleDriver"); conn = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:XE", "dms", "dms"); return conn; } catch (Exception e) { e.printStackTrace(); return null; ... |
Connection | getOracle10GConnection(String connIP, String port, String dbName, String username, String password) get Oracle G Connection Connection conn = null; try { Class.forName("oracle.jdbc.driver.OracleDriver"); conn = DriverManager.getConnection( "jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)" + "(HOST=" + connIP + ")(PORT=" + port + ")))" + "(CONNECT_DATA=(SID=" + dbName + ")))", username, password); } catch (ClassNotFoundException e) { ... |
Connection | getOracleConn() get Oracle Conn try { Class.forName(pros.getProperty("oracleDriver")); return DriverManager.getConnection(pros.getProperty("oracleURL"), pros.getProperty("oracleUser"), pros.getProperty("oraclePwd")); } catch (Exception e) { e.printStackTrace(); return null; |
Connection | getOracleConnection() get Oracle Connection String driver = "oracle.jdbc.driver.OracleDriver"; String url = "jdbc:oracle:thin:@localhost:1521:caspian"; String username = "mp"; String password = "mp2"; Class.forName(driver); Connection conn = DriverManager.getConnection(url, username, password); return conn; |