Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
1 changed file
with
48 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
} | ||
|
||
} |