


JDBC是Java数据库连接(Java Database Connectivity),一套操作数据库的规范接口。这套规范接口,经过多次版本迭代,目前使用最多的规范接口是JDBC4.x。关于JDBC规范相关的说明,请参考本文后续中的参考资料章节。

jdbc:postgresql://ip:port/dbname
这种方式是AntDB最初提供的驱动中使用的连接方式,为了兼容PostgreSQL的使用习惯,因此进行了保留;
jdbc:antdb://ip:port/dbname
这种方式是目前AntDB主推的连接方式,用于区分AntDB与其他数据库的连接方式。
String url = "jdbc:antdb://10.1.1.1:6655/antdb?grammar=oracle";String user = "user";String password = "xxxx";Connection conn = null;try {conn = DriverManager.getConnection(url, user, password);conn.setAutoCommit(false);PreparedStatement psmt = conn.prepareStatement("insert into test1 values(?,'abc')");for(int i = 1; i <= 10; i ++){psmt.setInt(1,i);psmt.execute();}conn.commit();psmt.close();conn.close();}catch (SQLException ex){System.out.println(ex.getMessage());}finally {if(conn != null) {conn.close();}}

1.双引擎支持
oracle
postgres
oracle
postgres
alter system set grammar to oracle ;select pg_reload_conf();
2.安全加强
3.批量删除性能优化
PreparedStatement psmt = conn.prepareStatement("delete from t where c1=?");for(int i = 1; i <= 100; i ++){psmt.setInt(1,i);psmt.addBatch();}psmt.executeBatch();

reWriteBatchedDeletes=true时,jdbc驱动内部会改写SQL,将上述SQL会改写成:delete from t1 where id in (1,2,3...) reWriteBatchedDeleteSize指定时,改写后的SQL会按照指定的批次进行删除,例如reWriteBatchedDeleteSize设置为3时,改写后的SQL就以3为单位,对所有数据分批执行,例如,'delete from t1 where id in (1,2,3)','delete from t1 where id in (4,5,6)'......

4. Oracle兼容性增强
varchar2 nvarchar2 rowid oracle.date raw
CallableStatement.getNString(int) PreparedStatement.setNString(int, String) ResultSet.getNString(int) ResultSet.getNString(String)

PreparedStatement.setNClob CallableStatement.getNClob ResultSet.getNClob PreparedStatement.setNCharacterStream CallableStatement.getNCharacterStream ResultSet.getNCharacterStream Etc.

JDBC 4.1 Specification (JDBC 4.1). Available at https://download.oracle.com/otndocs/jcp/jdbc-4_1-mrel-spec/index.html JDBC 4.0 Specification (JDBC 4.0). Available at http://jcp.org/en/jsr/detail?id=221 JDBC 3.0 Specification (JDBC 3.0). Available at http://jcp.org/en/jsr/detail?id=54 JDBC 2.1 API (JDBC 2.1). Available at http://www.oracle.com/technetwork/java/download-141179.html JDBC 2.0 Standard Extension API (JDBC extension specification). Available at http://www.oracle.com/technetwork/java/download-141179.html JDBC 1.22 API (JDBC 1.22). Available at http://www.oracle.com/technetwork/java/download-141179.html
亚信安慧AntDB的JDBC相关资料:
手册:https://jdbc.postgresql.org/documentation/、http://www.antdb.net/72_product
下载:http://www.antdb.net/download
AntDB的口令认证方式:https://www.postgresql.org/docs/current/auth-password.html
关于亚信安慧AntDB数据库
AntDB数据库始于2008年,在运营商的核心系统上,服务国内24个省市自治区的数亿用户,具备高性能、弹性扩展、高可靠等产品特性,峰值每秒可处理百万笔通信核心交易,保障系统持续稳定运行超十年,并在通信、金融、交通、能源、物联网等行业成功商用落地。




文章转载自AntDB数据库,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。




