Skip to content
Permalink
Browse files
JavaDb
  • Loading branch information
sareenv committed Feb 8, 2019
1 parent 3fd9234 commit 89161378407d2e15c50146f256389c32b5f23909
Showing 1 changed file with 48 additions and 0 deletions.
48 JavaDb
@@ -0,0 +1,48 @@
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();
}

}

0 comments on commit 8916137

Please sign in to comment.