Skip to content

Commit

Permalink
continue DB
Browse files Browse the repository at this point in the history
  • Loading branch information
Abdelrhman-Ellithy committed Nov 1, 2024
1 parent 1d73d97 commit cf614e8
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 8 deletions.
1 change: 0 additions & 1 deletion src/main/java/Ellithium/core/DB/NoSQLDatabaseProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ public NoSQLDatabaseProvider(DBType dbType, String connectionString, String dbNa
.expireAfterWrite(10, TimeUnit.MINUTES)
.maximumSize(100)
.build();

initializeConnection(connectionString, dbName, username, password);
}

Expand Down
7 changes: 1 addition & 6 deletions src/main/java/Ellithium/core/DB/SQLDatabaseProvider.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
package Ellithium.core.DB;

import Ellithium.core.logging.LogLevel;
import Ellithium.core.reporting.Reporter;
import com.github.benmanes.caffeine.cache.Cache;
Expand Down Expand Up @@ -41,7 +40,7 @@ public class SQLDatabaseProvider {
dbTypeConnectionMap.put(DBType.IBM_DB2, "jdbc:db2://");
}

public SQLDatabaseProvider(String userName, String password, String port, String dataBaseName, String serverIP, DBType dbType) {
public SQLDatabaseProvider( DBType dbType,String userName, String password,String serverIP, String port, String dataBaseName) {
this.userName = userName;
this.password = password;
this.port = port;
Expand All @@ -57,10 +56,8 @@ public SQLDatabaseProvider(String userName, String password, String port, String
config.setConnectionTimeout(30000);
config.setIdleTimeout(600000);
config.setMaxLifetime(1800000);

this.dataSource = new HikariDataSource(config);
Reporter.log("Initialized SQLDatabaseProvider with HikariCP connection pool.", LogLevel.INFO_BLUE);

columnNamesCache = Caffeine.newBuilder().expireAfterWrite(10, TimeUnit.MINUTES).maximumSize(100).build();
rowCountCache = Caffeine.newBuilder().expireAfterWrite(10, TimeUnit.MINUTES).maximumSize(100).build();
columnDataTypesCache = Caffeine.newBuilder().expireAfterWrite(10, TimeUnit.MINUTES).maximumSize(100).build();
Expand All @@ -71,10 +68,8 @@ public CachedRowSet executeQuery(String query) {
try (Connection connection = dataSource.getConnection();
Statement statement = connection.createStatement();
ResultSet resultSet = statement.executeQuery(query)) {

CachedRowSet rowSet = RowSetProvider.newFactory().createCachedRowSet();
rowSet.populate(resultSet);

Reporter.log("Executed query successfully: " + query, LogLevel.INFO_BLUE, "Success");
return rowSet;

Expand Down
1 change: 0 additions & 1 deletion src/main/java/Ellithium/core/driver/DriverSetUp.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package Ellithium.core.driver;
import Ellithium.core.logging.LogLevel;
import Ellithium.core.reporting.Reporter;
import org.jetbrains.annotations.NotNull;
import org.openqa.selenium.PageLoadStrategy;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
Expand Down
14 changes: 14 additions & 0 deletions src/test/java/Tests/DBTEst.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package Tests;

import Ellithium.core.DB.DBType;
import Ellithium.core.DB.SQLDatabaseProvider;
import org.testng.annotations.Test;

public class DBTEst {
@Test
public void testDB(){
SQLDatabaseProvider db=new SQLDatabaseProvider(DBType.MY_SQL,"remote_user","Appy@innovate", "10.147.17.34","3306","webinvoice_bigdata");
var rs=db.getColumnNames("item");
System.out.println(rs);
}
}

0 comments on commit cf614e8

Please sign in to comment.