7 messages in com.mysql.lists.javaRe: Connector/J versions| From | Sent On | Attachments |
|---|---|---|
| Ales Vaupotic | 13 Feb 2004 03:16 | |
| Mark Matthews | 13 Feb 2004 06:57 | |
| Ales Vaupotic | 14 Feb 2004 15:10 | |
| Mark Matthews | 14 Feb 2004 16:39 | |
| Ales Vaupotic | 15 Feb 2004 06:42 | |
| Mark Matthews | 15 Feb 2004 08:57 | |
| Ales Vaupotic | 15 Feb 2004 10:00 |
| Subject: | Re: Connector/J versions![]() |
|---|---|
| From: | Ales Vaupotic (ales...@email.si) |
| Date: | 02/14/2004 03:10:19 PM |
| List: | com.mysql.lists.java |
Hi, Mark!
Mark Matthews pravi:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
Ales Vaupotic wrote:
Hello, list!
With Tomcat, I am trying to switch over to JDBCRealm from simple file based realm. An here comes the problem. My whole application is based on cp1250. MySQL is set to cp1250, all web content is in windows-1250, ...... I can't change that! Anyway, with Connector/J, I found only the latest 3.1 version (unstable or nightly) to work OK with cp1250. It took me quite a while, to find that out. Maybe it's written somewhere in the docs, but I haven't read it because I was sure the problem it can't be in connector/J!
Now, when I am turning over my realms, I get some strange errors while authenticating. Every time I restart catalina, only the first authentication is successful. All of the following authentications fail with this error:
SEVERE: An exception or error occurred in the container during the request proces java.lang.NullPointerException at org.apache.catalina.realm.JDBCRealm.authenticate(JDBCRealm.java:469) at org.apache.catalina.realm.JDBCRealm.authenticate(JDBCRealm.java:393) ........ I am using Win2K, SP4, JDK 1.4.2_03, Tomcat 5.0.18, MySQL 4.1.1, Connector/J 3.1/com.mysql.jdbc (tried org.... also, doesn't work either)
What's really annoying is the fact that the stable 3.0.10 connector works perfectly for authentication, but does not deliver the contents in correct character set !!!
Aaarghhhh! Can someone, please, suggest a solution for my problem?
Calm sea to you all!
Ales
Ales,
I'm surprised to find that Connector/J 3.0.10 is not working for you, as the character sets code is the same between the 3.0.x and 3.1.x branches of the product.
I am sorry, but this is really happening. I couldn't believe it myself either, but when I replace the connector versions ( and nothing else, it takes me 30 second to restart!) things go wrong as written.
Could you post the various configuration items that you have altered, such as your the portion of your server.xml that you use for JDBCRealm, any DataSources you have setup, and what any 'non-standard' configuration values you have used for the MySQL server (for example, do you change the default character set to be cp1250, do any of your tables define their character set to be cp1250, etc).
Without this information, it would be pretty difficult to surmise what's going on.
Here is the data about my realm database and tables:
mysql> show create database alesdb;
+----------+-------------------------------------------------------------------+ | Database | Create Database |
+----------+-------------------------------------------------------------------+ | alesdb | CREATE DATABASE `alesdb` /*!40100 DEFAULT CHARACTER SET cp1250 */ |
+----------+-------------------------------------------------------------------+ 1 row in set (0.00 sec)
mysql> show create table users;
+-------+-------------------------------------------------------------------------------------------------------------------------------------------- -------------------------------------------+ | Table | Create Table |
+-------+-------------------------------------------------------------------------------------------------------------------------------------------- -------------------------------------------+ | users | CREATE TABLE `users` ( `user_name` varchar(15) NOT NULL default '', `user_pass` varchar(15) NOT NULL default '', PRIMARY KEY (`user_name`) ) TYPE=MyISAM DEFAULT CHARSET=latin1 |
+-------+-------------------------------------------------------------------------------------------------------------------------------------------- -------------------------------------------+ 1 row in set (0.00 sec)
mysql> show create table user_roles;
+------------+--------------------------------------------------------------------------------------------------------------------------------------- -----------------------------------------------------------------+ | Table | Create Table |
+------------+--------------------------------------------------------------------------------------------------------------------------------------- -----------------------------------------------------------------+ | user_roles | CREATE TABLE `user_roles` ( `user_name` varchar(15) NOT NULL default '', `role_name` varchar(15) NOT NULL default '', PRIMARY KEY (`user_name`,`role_name`) ) TYPE=MyISAM DEFAULT CHARSET=latin1 |
+------------+--------------------------------------------------------------------------------------------------------------------------------------- -----------------------------------------------------------------+ 1 row in set (0.00 sec)
I am starting mysql thru WinMySQL and it uses the folowing my.ini to start it:
[mysqld] basedir=C:/mysql-4.1.1-alpha datadir=C:/mysql-4.1.1-alpha/data set-variable=default-character-set=cp1250
[WinMySQLadmin] Server=C:/mysql-4.1.1-alpha/bin/mysqld-max-nt.exe user=amanita1 password=rmsksulp QueryInterval=3
[client] character-sets-dir=C:/mysql-4.1.1-alpha/share/charsets set-variable=default-character-set=cp1250
Server variables: character_set_server cp1250 character_set_system utf8 character_set_database cp1250 character_set_client cp1250 character_set_connection cp1250 character-sets-dir C:\mysql-4.1.1-alpha\share\charsets/ character_set_results cp1250 collation_connection cp1250_general_ci collation_database cp1250_general_ci collation_server cp1250_general_ci
Here is my realm definition in server.xml
<Realm className="org.apache.catalina.realm.JDBCRealm" debug="99" driverName="com.mysql.jdbc.Driver" connectionURL="jdbc:mysql://localhost/alesdb" connectionName="baza" connectionPassword="baza" userTable="users" userNameCol="user_name" userCredCol="user_pass" userRoleTable="user_roles" roleNameCol="role_name"/>
Thanks!
-Mark
- -- Mr. Mark Matthews MySQL AB, Software Development Manager, J2EE and Windows Platforms Office: +1 708 332 0507 www.mysql.com
Meet the MySQL Team! April 14-16, 2004 http://www.mysql.com/uc2004/ -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.3 (MingW32) Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org
iD8DBQFALOXctvXNTca6JD8RAsK3AJ44p5tmFzd026mwqwUw1x7sYVphLQCeOUQC eYM6+L+uzFTjkk3REc3nbcs= =KVmy -----END PGP SIGNATURE-----
Do you think the latin1 coding on user and user_roles tables could be the problem? I had to change that because if I let the tables in cp1250 as database default, than I get the error of incompatible collation sequences between swedish and cp1250. If I try to expand my connectionURL to something that works in my application, like
connectionURL="jdbc:mysql://localhost/alesdb?characterEncoding=cp1250"
I still get the same error message in Tomcat log:
java.sql.SQLException: General error message from server: "Illegal mix of collations (cp1250_general_ci,IMPLICIT) and (latin1_swedish_ci,COERCIBLE) for operation '='"
I even tried (while searching for a solution to get my local characters working as expected) to expand the connectionURL with two parameters, like
connectionURL="jdbc:mysql://localhost/alesdb?useUnicode=true&characterEncoding=cp1250"
This normally works in my app, but I get the error from Tomcat startup:
C:\tomcat\bin>catalina run Using CATALINA_BASE: c:\tomcat Using CATALINA_HOME: c:\tomcat Using CATALINA_TMPDIR: c:\tomcat\temp Using JAVA_HOME: c:\java 2004.2.14 23:21:18 org.apache.commons.digester.Digester fatalError SEVERE: Parse Fatal Error at line 191 column 82: The reference to entity "characterEncoding" must end with the ';' delimiter. org.xml.sax.SAXParseException: The reference to entity "characterEncoding" must end with the ';' delimiter. at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
Like there is something wrong with the ampersand. If I change this URL to
connectionURL="jdbc:mysql://localhost/alesdb?useUnicode=true;characterEncoding=cp1250;"
which already doesn't agree with your syntax as stated in the manual:
" The JDBC URL format for MySQL Connector/J is as follows, with items in square brackets ([, ]) being optional:
jdbc:mysql://[host][,failoverhost...][:port]/[database][?propertyName1][=propertyValue1][&propertyName2][=propertyValue2]...
"
I get Tomcat to fire-up, but log says there is something wrong with my parameters: 2004-02-14 23:30:51 JDBCRealm[Catalina]: Exception opening database connection java.sql.SQLException: The connection property 'useUnicode' only accepts values of the form: 'true', 'false', 'yes' or 'no'. The value 'true;characterEncoding' is not in this set. at com.mysql.jdbc.ConnectionProperties$ConnectionProperty.validateStringValues(ConnectionProperties.java:1452)
So, I found no other way but changing the two realm tables to latin1 and forgetting the extended format of my connectionURL.
I can expose the following fragments of my log and tomcat console (pay attention to timestamps):
log:
2004-02-14 23:41:31 JDBCRealm[Catalina]: Username amanita1 successfully
authenticated
2004-02-14 23:41:32 JDBCRealm[Catalina]: Username amanita1 successfully
authenticated
console:
2004.2.14 23:41:25 org.apache.catalina.startup.Catalina start INFO: Server startup in 4516 ms 2004.2.14 23:41:34 org.apache.coyote.tomcat5.CoyoteAdapter service SEVERE: An exception or error occurred in the container during the request processing java.lang.NullPointerException at org.apache.catalina.realm.JDBCRealm.authenticate(JDBCRealm.java:469) at org.apache.catalina.realm.JDBCRealm.authenticate(JDBCRealm.java:393) at org.apache.catalina.authenticator.BasicAuthenticator.authenticate(BasicAuthenticator.ja..........
As you can see, I startet Tomcat at second 25, navigated to status page, logged in at second 31 and when I got the list of my applications at second 32, I tried to log in with another instance of IE after 2 seconds. It failed. It looks like it works while in the same first session.
Thanks for your time, Mark. Hope you can recreate the problem and help me solve it. I'll continue to search for solution but as I am not very familiar with Tomcat, it might take some time. -Ales




