34 lines
1.0 KiB
Java
34 lines
1.0 KiB
Java
package me.arcodeskel.uwpmcutils.commands;
|
|
import com.zaxxer.hikari.HikariConfig;
|
|
import com.zaxxer.hikari.HikariDataSource;
|
|
|
|
import java.sql.Connection;
|
|
import java.sql.SQLException;
|
|
|
|
|
|
public class DatabaseConnection {
|
|
private static final HikariDataSource dataSource;
|
|
|
|
static {
|
|
HikariConfig config = new HikariConfig();
|
|
config.setJdbcUrl("jdbc:sqlite:data.db"); // Your SQLite database path
|
|
config.setUsername(""); // Not needed for SQLite
|
|
config.setPassword(""); // Not needed for SQLite
|
|
config.setMaximumPoolSize(10); // Adjust as needed
|
|
config.setConnectionTestQuery("SELECT 1"); // Test query
|
|
|
|
dataSource = new HikariDataSource(config);
|
|
}
|
|
|
|
public static Connection getConnection() throws SQLException {
|
|
return dataSource.getConnection();
|
|
}
|
|
|
|
public static void close() {
|
|
if (dataSource != null) {
|
|
dataSource.close();
|
|
}
|
|
}
|
|
}
|
|
|