关系型数据库(firebird)
·
概述
Firebird 是一款开源的关系型数据库系统,以其高性能、强事务支持和跨平台能力在中小型系统中广泛应用。
maven依赖
<dependency>
<groupId>org.firebirdsql.jdbc</groupId>
<artifactId>jaybird</artifactId>
<version>5.0.10.java8</version>
</dependency>
示例
- 驱动链接示例
@Test
void contextLoads1() throws ClassNotFoundException, SQLException {
Class.forName("org.firebirdsql.jdbc.FBDriver");
Connection connection = DriverManager.getConnection("jdbc:firebirdsql:localhost/3050:D:\\DBSTWO.FDB","userName", "******");
Statement statement = connection.createStatement();
//查询数据
ResultSet resultSet = statement.executeQuery("select * from sys_user limit 10");
while (resultSet.next()) {
int id = resultSet.getInt("user_id");
String name = resultSet.getString("user_name");
System.out.println("id: " + id + " name: " + name);
}
}
- 数据源链接示例
@Test
void contextLoads() throws SQLException {
FBSimpleDataSource ds = new FBSimpleDataSource();
ds.setDatabase("localhost:E:\\workspace\\MyStudyProject\\DbStudy\\src\\test\\resources\\db\\firebird.fdb");
ds.setUser("sysdba");
ds.setPassword("masterkey");
Connection connection = ds.getConnection();
}
可参考文档
更多推荐
所有评论(0)