Compiling with mysql

ezer andres.a@adinet.com.uy
Wed Sep 3 16:06:00 GMT 2008


1) I found whats going on, its an incompatibility in the character conversion
between the gcj and mysql. Here is the explanation and the workaround :
http://dev.mysql.com/doc/refman/5.0/en/connector-j-usagenotes-troubleshooting.html#qandaitem-28-4-5-3-9
http://bugs.mysql.com/bug.php?id=29636
(go to the post [9 Jul 2007 17:05])
2) I added 
default-character-set=utf8
under [client] and [mysqld] sections of the my.cnf file of mysql
3) The other solution of using useJvmCharsetConverters=true i didnt tested
because i dont know where to use that string.
4) Now i get the test program runing fine with the following output:
MySQL Connect Example.
Connected to the database
Disconnected from database
But one thing is that the connection executing under the gcj program runs
considerable slower than the same test runing with java MysqlConnect. Its
normal for connections ? 
Andrew Haley wrote:
>> ezer wrote:
>> Andrew, i dont understand what do you mean with exactly, I will try to
>> explain again, i isolated the problem only compiling a short code that
>> only
>> conects to the database and exit. 
>>>> 1) The code is the following
>>>> import java.sql.*;
>>>> public class MysqlConnect{
>> public static void main(String[] args) {
>> System.out.println("MySQL Connect Example.");
>> Connection conn = null;
>> String url = "jdbc:mysql://localhost:3306/";
>> String dbName = "myDatabase";
>> String driver = "com.mysql.jdbc.Driver";
>> String userName = "root";
>> String password = "root";
>> try {
>> Class.forName(driver).newInstance();
>> conn = DriverManager.getConnection(url+dbName,userName,password);
>> System.out.println("Connected to the database");
>> conn.close();
>> System.out.println("Disconnected from database");
>> } catch (Exception e) {
>> e.printStackTrace();
>> }
>> }
>> }
>> As far as I can tell the error message is not coming from gcj,
> but from mysql. It's quite possible that this is caused by
> a bug in gcj, but I'd have to debug it to know for sure. Is
> there a log from mysql?
>> Andrew.
>>> 2) I compile
>> gcj --main=MysqlConnect -o mysqlconnect MysqlConnect.java
>>>> (gcj version : 4.3.1)
>>>> 3) Execution:
>>>> ./mysqlconnect
>>>> 4) Output:
>>>> MySQL Connect Example.
>> 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
>> at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:936)
>> at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2985)
>> at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1631)
>> at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1723)
>> at com.mysql.jdbc.Connection.execSQL(Connection.java:3277)
>> at
>> com.mysql.jdbc.Connection.configureClientCharacterSet(Connection.java:2525)
>> at
>> com.mysql.jdbc.Connection.initializePropsFromServer(Connection.java:4139)
>> at com.mysql.jdbc.Connection.createNewIO(Connection.java:2789)
>> at com.mysql.jdbc.Connection.<init>(Connection.java:1555)
>> at
>> com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:285)
>> at java.sql.DriverManager.getConnection(libgcj.so.90)
>> at java.sql.DriverManager.getConnection(libgcj.so.90)
>> at MysqlConnect.main(MysqlConnect.java:14)
>>>> 5) I installed a previous version of gcj 4.2 and repetead the compilation
>> and execution, and the result was the following:
>>>> MySQL Connect Example.
>> java.sql.SQLException: Error during query: Unexpected Exception:
>> java.io.CharConversionException message given: null
>>>> Nested Stack Trace:
>>>>>> ** BEGIN NESTED EXCEPTION ** 
>>>> java.io.CharConversionException
>>>> STACKTRACE:
>>>> java.io.CharConversionException
>> at gnu.gcj.convert.Input_iconv.read(libgcj.so.81)
>> at java.lang.String.init(libgcj.so.81)
>> at java.lang.String.<init>(libgcj.so.81)
>> at
>> com.mysql.jdbc.SingleByteCharsetConverter.<init>(SingleByteCharsetConverter.java:153)
>> at
>> com.mysql.jdbc.SingleByteCharsetConverter.initCharset(SingleByteCharsetConverter.java:108)
>> at
>> com.mysql.jdbc.SingleByteCharsetConverter.getInstance(SingleByteCharsetConverter.java:86)
>> at com.mysql.jdbc.Connection.getCharsetConverter(Connection.java:3505)
>> at com.mysql.jdbc.StringUtils.getBytes(StringUtils.java:615)
>> at com.mysql.jdbc.Buffer.writeStringNoNull(Buffer.java:655)
>> at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1686)
>> at com.mysql.jdbc.Connection.execSQL(Connection.java:3277)
>> at
>> com.mysql.jdbc.Connection.configureClientCharacterSet(Connection.java:2525)
>> at
>> com.mysql.jdbc.Connection.initializePropsFromServer(Connection.java:4139)
>> at com.mysql.jdbc.Connection.createNewIO(Connection.java:2789)
>> at com.mysql.jdbc.Connection.<init>(Connection.java:1555)
>> at
>> com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:285)
>> at java.sql.DriverManager.getConnection(libgcj.so.81)
>> at java.sql.DriverManager.getConnection(libgcj.so.81)
>> at MysqlConnect.main(mysqlconnect)
>>>>>> ** END NESTED EXCEPTION **
>>>>>> at com.mysql.jdbc.Connection.execSQL(Connection.java:3330)
>> at
>> com.mysql.jdbc.Connection.configureClientCharacterSet(Connection.java:2525)
>> at
>> com.mysql.jdbc.Connection.initializePropsFromServer(Connection.java:4139)
>> at com.mysql.jdbc.Connection.createNewIO(Connection.java:2789)
>> at com.mysql.jdbc.Connection.<init>(Connection.java:1555)
>> at
>> com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:285)
>> at java.sql.DriverManager.getConnection(libgcj.so.81)
>> at java.sql.DriverManager.getConnection(libgcj.so.81)
>> at MysqlConnect.main(mysqlconnect)
>>>> 6) It seems it cant execute the line conn =
>> DriverManager.getConnection(url+dbName,userName,password);
>> From the same machine executing with java sun, it did well, but not with
>> the
>> java version from the gcj.. 
>>>> It was exactly what i did.. dont know what else could i add.
>>>>>>>>>>>>>>>> Andrew Haley wrote:
>>> ezer wrote:
>>>> New try:
>>>>>>>> I generated mysql-connector-java-5.0.8-bin.o
>>>> and used it in the compilation of the program
>>>> gcj --main=Search --classpath=mysql-connector-java-5.0.8-bin.o 
>>>> Searcher.jar
>>>> -o search
>>>>>>>> It compiles without errors, but when i execute ./search i get
>>>> segmentation
>>>> fault
>>>>>>>> I dont know what to do.. help please...
>>> the key problem here is that you haven't told us *exactly* what you are
>>> doing. We need to know if we can help you.
>>>>>> http://www.catb.org/~esr/faqs/smart-questions.html
>>>>>> Andrew.
>>>>>>>>>>>>>>>>>
-- 
View this message in context: http://www.nabble.com/Compiling-with-mysql-tp19092090p19292423.html
Sent from the gcc - java mailing list archive at Nabble.com.


More information about the Java mailing list

AltStyle によって変換されたページ (->オリジナル) /