我正在尝试使用纯JDBC方法从Java以查询加速器模式执行SQL查询。也就是说,从DriverManager
创建连接并执行查询。但是扔com.ibm.db2.jcc.am.SqlSyntaxErrorException
为此,我在IBM文档中提到了在连接URL中设置特殊参数的方法。
表已经移至IBM DB2 Analytics Accelerator(IDAA)服务器,并且我能够从AQT工具(“我的数据库”客户端工具)以加速模式执行查询,并且该表运行速度非常快。
我使用了db2jcc4
驱动程序Type4
,下面给出了连接URL和Connection类:
public class ConnectionManager {
private static final Logger LOGGER = LoggerFactory.getLogger(ConnectionManager.class);
private static String url = "jdbc:db2://myIP:myPort/myDBName:specialRegisters=CURRENT QUERY ACCELERATION=ELIGIBLE";
private static String driverName = "com.ibm.db2.jcc.DB2Driver";
private static String username = "user";
private static String password = "pwd";
private static Connection con;
private static String urlstring;
public static Connection getConnection() throws SQLException, ClassNotFoundException {
try {
Class.forName(driverName);
try {
con = DriverManager.getConnection(url, username, password);
} catch (SQLException ex) {
// log an exception. fro example:
System.out.println("Failed to create the database connection.");
throw ex;
}
} catch (ClassNotFoundException ex) {
// log an exception. for example:
System.out.println("Driver not found.");
throw ex;
}
return con;
}
}
有什么我想念或做错的事吗?
com.ibm.db2.jcc.am.SqlSyntaxErrorException: [jcc][10165][10051][4.24.92] Invalid database URL syntax: jdbc:db2://IP:Port/DBName:specialRegisters=CURRENT QUERY ACCELERATION=ELIGIBLE. ERRORCODE=-4461, SQLSTATE=42815
at com.ibm.db2.jcc.am.b6.a(b6.java:810)
at com.ibm.db2.jcc.am.b6.a(b6.java:66)
at com.ibm.db2.jcc.am.b6.a(b6.java:98)
at com.ibm.db2.jcc.DB2Driver.tokenizeURLProperties(DB2Driver.java:950)
at com.ibm.db2.jcc.DB2Driver.connect(DB2Driver.java:413)
at com.ibm.db2.jcc.DB2Driver.connect(DB2Driver.java:113)
at java.sql.DriverManager.getConnection(DriverManager.java:664)
at java.sql.DriverManager.getConnection(DriverManager.java:247)
at colruyt.spcpocxpsejb.util.ConnectionManager.getConnection(ConnectionManager.java:38)
at colruyt.spcpocxpsejb.util.TestUtility.testAOT(TestUtility.java:98)
at colruyt.spcpocxpsejb.util.TestUtility.main(TestUtility.java:25)
Caused by: java.util.NoSuchElementException
at java.util.StringTokenizer.nextToken(StringTokenizer.java:349)
at java.util.StringTokenizer.nextToken(StringTokenizer.java:377)
at com.ibm.db2.jcc.DB2Driver.tokenizeURLProperties(DB2Driver.java:938)
... 7 more