Re: Compiling with mysql

Andrew Haley <[email protected]>
Newsgroups gmane.comp.gcc.java.devel
Message-ID <[email protected]>
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.
>>
>>
>>
>>
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.