<repositories>
<repository>
<id>eld</id>
<url>https://maven.pkg.github.com/ELDependenci/eldependenci-sql</url>
</repository>
</repositories>
<dependency>
<groupId>org.eldependenci</groupId>
<artifactId>eldependenci-sql</artifactId>
<version>{{版本}}</version>
<scope>provided</scope>
</dependency>
public class SQLManager {
@Inject
private SQLService sqlService;
public void doSQLShit(){
try (Connection c = sqlService.getConnection(); PreparedStatement s = c.prepareStatement("select * from User")){
ResultSet set = s.executeQuery();
while (set.next()){
String username = set.getString("username");
System.out.println(username);
}
} catch (SQLException e) {
e.printStackTrace();
}
}
}
# 啟用 eld-sql, 不啟用無法掛接服務
enable: true
# 選擇你的資料庫類型,目前選擇 sqlite
dataSource: "sqlite"
sqlite:
file: "central.db"
mysql:
host: 127.0.0.1
port: 3306
database: database
username: username
password: password
useSSL: false
pool:
name: SQL-Pool
minSize: 5
maxSize: 10
connectionTimeout: 30000
idleTimeout: 60000
maxLifeTime: 600000