PowerBuilder中使用JDBC连接MYSQL

遇到的错误:

 long ll_count 
// Profile mysql
SQLCA.DBMS = "JDBC"
SQLCA.LogPass = "123"
SQLCA.LogId = "root"
SQLCA.AutoCommit = False
SQLCA.DBParm = "Driver='com.mysql.jdbc.Driver',URL='jdbc:mysql://localhost:3306/his' " 
connect using sqlca; 

select count(*) into :ll_count from yk_cddz;
登录后复制

很简单的一条语句,竟然报错了!

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '*) from yk_cddz' at line 1

找了百度没有人写个贴子,于是查看MYSQL的使用手册,终于在

Function Name Parsing and Resolution小节有说明


如果是用C语言API来操作,可以指定CLIENT_IGNORE_SPACE 参数,ODBC驱动中也有Ignore Space Afrer Function Names 这个选项,但是官方的JDBC中的没有这个选项。所以,要使用MYSQ 语句来设置。

Powerbuilder中的设置

 string sql  
 long ll_count
 sql = "SET sql_mode = 'IGNORE_SPACE' "  
EXECUTE IMMEDIATE :sql ; 
select count(*) into :ll_count from yk_cddz;
登录后复制

这样操作就不会有错误了,可以得到正确结果了,在这里写个贴子,希望有同样问题的朋友可以借鉴。
08-25 10:27