soliddb-mysql-5.0.27, jdbc 无法连接,已经发到..
时间:2007-03-16 来源:likuku
默认的 latin1 没问题。
ubuntu 6.06 sun.com jdk 1.6
mysql.com 下载的 官方 jdbc 驱动:
mysql-connector-java-3.1.12
mysql-connector-java-3.1.14
mysql-connector-java-5.0.5
soliddb.com 提供的 solid-mysql-5.0.27 无论是用源码编译,还是用 官方提供的 2进制发行版,
soliddb 存储引擎目前只支持 latin1 和 ucs2 字符集,因为肯定要存储中文,所以只能用ucs2。
只要使用 Soliddb 存储引擎,jdbc 就没法连接数据库。出现以下提示:
Can`t connect this Database,has this error: com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: 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 '??' at line 1 |
关闭 soliddb 存储引擎,或者 [mysqld]不使用ucs2 字符集,重启mysqld 就没问题了。
ubuntu 默认是 utf8 编码环境,我为了避免因为 utf8 编码问题,专门将系统分别在 POSIX C 和 zh_CN.UTF-8 环境, utf8 和 anscii 两个版本的 测试 java 源代码,分别编译 的 条件下测试,结果一致,都是上面出错提示。
solidb.com 的官方手册也说jdbc 直接用 mysql.com 提供的就成。我分别用3个版本的 jdbc 也是同样错误。
uname -a
Linux likuku.test.net 2.6.15-27-386 #1 PREEMPT Fri Dec 8 17:51:56 UTC 2006 i686 GNU/Linux |
版本信息和数据库信息:
solidmysql-5.0.27-linux-i686-0059.tar.gz root@likuku:/opt/mysql# ./bin/mysqld_safe --user=mysql & [1] 8258 root@likuku:/opt/mysql# Starting mysqld daemon with databases from /opt/mysql/data root@likuku:/opt/mysql# ./bin/mysql -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 1 to server version: 5.0.27 Type 'help;' or '\h' for help. Type '\c' to clear the buffer. mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | test | +--------------------+ 3 rows in set (0.13 sec) mysql> create database td; Query OK, 1 row affected (0.00 sec) mysql> use td Database changed mysql> create table tt (id int); Query OK, 0 rows affected, 1 warning (0.08 sec) mysql> show create table tt; +-------+---------------------------------------------------------------------------------------+ | Table | Create Table | +-------+---------------------------------------------------------------------------------------+ | tt | CREATE TABLE `tt` ( `id` int(11) default NULL ) ENGINE=solidDB DEFAULT CHARSET=ucs2 | +-------+---------------------------------------------------------------------------------------+ 1 row in set (0.01 sec) mysql> |
solid-mysql 自己提供的 my.cnf
[client] port = 3306 socket = /tmp/mysql.sock # The MySQL server [mysqld] port = 3306 socket = /tmp/mysql.sock skip-locking thread_stack = 64K # These are solidDB parameters # default-storage-engine = soliddb soliddb_cache_size=128M soliddb_durability_level=3 default-character-set=ucs2 #默认是latin1,但是我要存储中文数据,最好还是 ucs2; 默认的latin1 没问题。但UTF是王道阿。 [mysqldump] quick max_allowed_packet = 16M [mysql] no-auto-rehash |
env 输出的环境配置信息:
<strong> SSH_AGENT_PID=7724 TERM=xterm DESKTOP_STARTUP_ID= SHELL=/bin/bash GTK_RC_FILES=/etc/gtk/gtkrc:/home/likuku/.gtkrc-1.2-gnome2 WINDOWID=33554524 USER=likuku JRE_HOME=/opt/java GNOME_KEYRING_SOCKET=/tmp/keyring-t4TEJj/socket SSH_AUTH_SOCK=/tmp/ssh-lZFfSI7677/agent.7677 SESSION_MANAGER=local/likuku.test.net:/tmp/.ICE-unix/7677 USERNAME=likuku DESKTOP_SESSION=default PATH=/opt/java/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/bin/X11:/usr/games GDM_XSERVER_LOCATION=local PWD=/home/likuku/src/java/jdbc-test-solid-mysql-5.0.27 JAVA_HOME=/opt/java LANG=C GDM_LANG=C GDMSESSION=default HISTCONTROL=ignoredups HOME=/home/likuku SHLVL=1 LANGUAGE=C GNOME_DESKTOP_SESSION_ID=Default LOGNAME=likuku DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-wA5mekCCJp,guid=2d2efa450cff56ee595cbac0ce723000 CLASSPATH=.:/opt/java/lib/tools.jar:/opt/java/lib/dt.jar:/opt/class/mysql-connector-java-5.0.5-bin.jar LESSOPEN=| /usr/bin/lesspipe %s DISPLAY=:0.0 LESSCLOSE=/usr/bin/lesspipe %s %s COLORTERM=gnome-terminal XAUTHORITY=/tmp/.gdmGRdmWN _=/usr/bin/env OLDPWD=/home/likuku/src/java </strong> |
测试 Ts.java 代码:
import com.mysql.jdbc.Driver; |