Skip to content
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
package dbjava;
import java.sql.*;
/**
*
* @author sareenv
*/
public class DBJava {
/**
* @throws java.sql.SQLException
*/
public void databaseConnection() throws SQLException{
// String connectionUrl = "jdbc:derby://localhost:1527/newdb";
String connectionUrl1 = "jdbc:mysql://us-cdbr-iron-east-03.cleardb.net/heroku_64c1b2d2353b04c";
String userName = "be0bd21ceb4d83";
String password = "ecaf4504";
Connection conn = DriverManager.getConnection(connectionUrl1, userName, password);
if (conn != null){
System.out.println("System is getting connection to the database");
Statement st;
st = conn.createStatement();
ResultSet rs = null;
// Start getting data from the database
String sqlQuery = "SELECT * FROM weakAuth";
rs = st.executeQuery(sqlQuery);
while(rs.next()){
System.out.println(rs.getString("email"));
}
}else{
System.out.println("Not connected to this yet");
}
}
public static void main(String[] args) throws SQLException {
// TODO code application logic here
DBJava dbConnection = new DBJava();
dbConnection.databaseConnection();
}
}