List of utility methods to do JDBC MySQL Connection
Connection | getDMPConn() get DMP Conn Class.forName("com.mysql.jdbc.Driver"); return DriverManager.getConnection( "jdbc:mysql://192.168.3.101:3306/DMPDATA?useUnicode=true&characterEncoding=UTF-8", "DMPUSER", "DMPUSER"); |
Connection | getGoogleCloudDBConnection() get Google Cloud DB Connection Class.forName("com.mysql.jdbc.Driver").newInstance(); Connection conn = null; try { String url = "jdbc:mysql://173.194.248.217:3306/USM Marketing Intelligence Database"; String user = "crgrass"; String pass = "Swan!1dive"; conn = DriverManager.getConnection(url, user, pass); } catch (SQLException ex) { ... |
List | getIonMassList() get Ion Mass List List<String[]> massList = new ArrayList(); try { Class.forName("com.mysql.jdbc.Driver"); String conUrl = "jdbc:mysql://localhost/FORMULA_STRUCTURE_RELATION"; Connection con = DriverManager.getConnection(conUrl, "bird", "bird2006"); Statement stmt = con.createStatement(); String sql = "SELECT FORMULA, MASS FROM ION_MASS order by MASS"; ResultSet rs = stmt.executeQuery(sql); ... |
Connection | getJdbcConnection(String host, int port, String name, String user, String password) get Jdbc Connection Connection conn = null; Properties connectionProps = new Properties(); connectionProps.put("user", user); connectionProps.put("password", password); try { conn = DriverManager.getConnection( "jdbc:mysql://" + host + ":" + port + "/" + name + "?useUnicode=yes&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull", ... |
Connection | getJtdsConnection() get Jtds Connection Class.forName("net.sourceforge.jtds.jdbc.Driver"); return DriverManager.getConnection("jdbc:jtds:sqlserver://localhost:1433/ebs_DATADUMP", "eve", "eve"); |
int | getMaxID() get Max ID Connection con = getRssminerDB(); Statement stat = con.createStatement(); ResultSet rs = stat.executeQuery("select max(id) from feed_data"); rs.next(); int max = rs.getInt(1); con.close(); return max; |
Connection | getMysqlCon(String ip, String port, String dbname, String username, String password) get Mysql Con Connection conn = null; try { String url = "jdbc:mysql://" + ip + ":" + port + "/" + dbname; Class.forName("com.mysql.jdbc.Driver"); conn = DriverManager.getConnection(url, username, password); } catch (ClassNotFoundException e) { e.printStackTrace(); } catch (SQLException e) { ... |
Connection | getMysqlConnection(final String url) Get a mysql connection from a URL. return getConnection(MYSQL_DRIVER_CLASSNAME, url);
|
Connection | getMySQLConnection(Properties props) get My SQL Connection if (props == null) { props = new Properties(); String url = props.getProperty("url") == null ? "jdbc:mysql://localhost:3306/" : props.getProperty("url"); String db = props.getProperty("db") == null ? "cdcol" : props.getProperty("db"); String driver = "com.mysql.jdbc.Driver"; if (props.getProperty("user") == null) { props.setProperty("user", "root"); ... |
Connection | getMySQLConnection(String cloudSqlInstance, String dbName, String userName, String password) get My SQL Connection hasDriver(); String connectionURL = String.format("jdbc:mysql://google/%s?cloudSqlInstance=%s&" + "socketFactory=com.google.cloud.sql.mysql.SocketFactory", dbName, cloudSqlInstance); Connection conn = DriverManager.getConnection(connectionURL, userName, password); return conn; |