Skip to content

Commit

Permalink
removed db password
Browse files Browse the repository at this point in the history
  • Loading branch information
ipaulaandreea committed Nov 15, 2024
1 parent 0ef1797 commit 6ea426e
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 19 deletions.
6 changes: 2 additions & 4 deletions active-record/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,12 @@ For convenience, we are storing the database configuration logic inside the same
// Credentials for in-memory H2 database.

private static final String JDBC_URL = "jdbc:h2:mem:testdb;DB_CLOSE_DELAY=-1";
private static final String USERNAME = "sa";
private static final String PASSWORD = "";



// Establish a database connection.

private static Connection connect() throws SQLException {
return DriverManager.getConnection(JDBC_URL, USERNAME, PASSWORD);
return DriverManager.getConnection(JDBC_URL);
}

// Initialize the table (required each time program runs
Expand Down
13 changes: 1 addition & 12 deletions active-record/src/main/java/com/iluwatar/activerecord/User.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
* THE SOFTWARE.
*/
package com.iluwatar.activerecord;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
Expand All @@ -48,16 +47,6 @@ public class User {
*/
private static final String JDBC_URL = "jdbc:h2:mem:testdb;DB_CLOSE_DELAY=-1";

/**
* Database username.
*/
private static final String USERNAME = "sa";

/**
* Database password.
*/
private static final String PASSWORD = "";

/**
* User ID.
*/
Expand Down Expand Up @@ -97,7 +86,7 @@ public User(
*/

private static Connection connect() throws SQLException {
return DriverManager.getConnection(JDBC_URL, USERNAME, PASSWORD);
return DriverManager.getConnection(JDBC_URL);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@
class UserTest {

private static final String JDBC_URL = "jdbc:h2:mem:testdb;DB_CLOSE_DELAY=-1";
private static final String USERNAME = "sa";
private static final String PASSWORD = "";

@BeforeAll
static void setupDatabase() throws SQLException {
Expand All @@ -48,7 +46,7 @@ static void setupDatabase() throws SQLException {
@BeforeEach
void clearDatabase() throws SQLException {
// Clean up table before each test
try (Connection conn = DriverManager.getConnection(JDBC_URL, USERNAME, PASSWORD);
try (Connection conn = DriverManager.getConnection(JDBC_URL);
Statement stmt = conn.createStatement()) {
stmt.execute("DELETE FROM users");
}
Expand Down

0 comments on commit 6ea426e

Please sign in to comment.