List of utility methods to do JDBC MySQL Connection
Connection | getMySQLConnection(String hostname, String databaseName, String dbuser, String dbpasswort) Gets the my sql connection. return getMySQLConnection(hostname, MYSQL_PORT, databaseName, dbuser, dbpasswort);
|
Connection | getMySQLConnection(String hostName, String dbName, String userName, String password) get My SQL Connection Class.forName("com.mysql.jdbc.Driver"); String connectionURL = "jdbc:mysql://localhost:3306/test1"; Connection conn = DriverManager.getConnection(connectionURL, userName, password); return conn; |
HashMap | getMysqlIndices(String conString) get Mysql Indices HashMap<String, HashSet<String>> result = new HashMap<String, HashSet<String>>(); Connection conn; conn = DriverManager.getConnection(conString); DatabaseMetaData meta = conn.getMetaData(); ResultSet tables = meta.getTables(null, null, null, null); while (tables.next()) { ResultSet rs; String tableName = tables.getString(3); ... |
Connection | getNewDatabaseConnection(String dbUser, String dbPassword) get New Database Connection lookupDriver();
return connectAndUseDatabase(dbUser, dbPassword);
|
Connection | getRssminerDB() get Rssminer DB Connection con = DriverManager.getConnection(JDBC_URL, "feng", ""); return con; |
Connection | getSearchReaderConnection() get Search Reader Connection if (searchReaderConnection == null || searchReaderConnection.isClosed()) { searchReaderConnection = DriverManager.getConnection("jdbc:mysql://localhost:3306/ycppquiz", "ycppquiz", "ycppquiz"); return searchReaderConnection; |
void | openConnection() open Connection try { Class.forName("com.mysql.jdbc.Driver"); mConn = DriverManager.getConnection("jdbc:mysql://localhost:3306/source_products", "root", "123"); mStmt = mConn.createStatement(); } catch (Exception e) { e.printStackTrace(); |
void | putData(int tID, String toolID) put Data Connection con = null; PreparedStatement preparedStatement = null; try { Class.forName("com.mysql.jdbc.Driver"); con = DriverManager.getConnection(dbUrl, user, password); preparedStatement = con.prepareStatement(addDataQ); preparedStatement.setInt(1, tID); preparedStatement.setString(2, toolID); ... |
ResultSet | query(String sql) query try { if (mStmt == null || mStmt.isClosed()) { openConnection(); return mStmt.executeQuery(sql); } catch (SQLException e) { e.printStackTrace(); return null; |
List
| queryAll(String sql, List query All List<List<Object>> result = new ArrayList<List<Object>>(); Connection connection = null; try { connection = DriverManager.getConnection(url, user, password); PreparedStatement ps = connection.prepareStatement(sql); if (params != null && params.size() > 0) { for (int i = 0; i < params.size(); i++) { ps.setObject(i + 1, params.get(i)); ... |