* Mysql and -static--libgcj
@ 2008-09-25 16:42 ezer
2008-09-26 3:26 ` Taufik Chowi
0 siblings, 1 reply; 4+ messages in thread
From: ezer @ 2008-09-25 16:42 UTC (permalink / raw)
To: java
I am triyng for a month to resolver some basic problems. Basically i made a
basic test that conects and disconects from a mysql database.
I posted some other message. i am opening a new one to explain it clear.
http://www.nabble.com/Performance-gcj---mysql-td19375453.html
http://www.nabble.com/Compiling-with-mysql-td19092090.html
I want that program test to run in a machine that doesnt have neither java
or gcj installed.
Other way to make this example distributable will help me.
Now i am testing on Mandriva 2009 b2
i installed gcj from the SOFTWARE MANAGMENT
# gcj --version
gcj (GCC) 4.3.2
I will expose 2 test i made.. I use for them 2 files, MysqlConnect.java and
the jar driver of mysql
-------*-------
MysqlConnect.java
-------*-------
import java.sql.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Vector;
public class MysqlConnect{
public static void main(String[] args) {
long startTime = System.currentTimeMillis();
System.out.println("MySQL Connect Example.");
Connection conn = null;
String dbName = "mysql";
String driver = "com.mysql.jdbc.Driver";
String userName = "root";
String password = "admin";
List rows = new ArrayList();
Statement stmt = null;
ResultSet rs = null;
try {
Class.forName(driver).newInstance();
conn =
DriverManager.getConnection("jdbc:mysql://localhost:3306/mysqltest?useJvmCharsetConverters=true&useOldUTF8Behavior=true",
userName, password);
System.out.println("Connected to the database");
stmt = conn.createStatement();
rs = stmt.executeQuery("SELECT id, titulo, descripcion FROM
mytable");
System.out.println("Query executed");
while (rs.next()) {
//System.out.println(rs.getInt("id") + ", "
+ rs.getString("titulo") + ", " + rs.getString("descripcion"));
Vector row = new Vector();
row.add(rs.getInt("id"));
row.add(rs.getString("titulo"));
row.add(rs.getString("descripcion"));
rows.add(row);
}
conn.close();
System.out.println("Disconnected from database");
} catch (Exception e) {
e.printStackTrace();
}
long stopTime = System.currentTimeMillis();
long elapsedTime = (stopTime - startTime) / 1000;
System.out.println("Execution Time: " + elapsedTime + " seconds");
}
}
-------*-------
TEST 1)
-------*-------
1) gcj -O2 -c mysql-connector-java-5.0.8-bin.jar -o mysql-5.0.8.o
-findirect-dispatch
2) gcj -O2 --main=MysqlConnect MysqlConnect.class mysql-5.0.8.o -o
MysqlConnect -static-libgcj
3) ./MysqlConnect
Exception in thread "main" java.lang.NoClassDefFoundError:
com.mysql.jdbc.ConnectionProperties$ConnectionProperty
at java.lang.Class.initializeClass(MysqlConnect)
at java.lang.Class.forName(MysqlConnect)
at java.lang.Class.forName(MysqlConnect)
at com.mysql.jdbc.ConnectionProperties.class$(MysqlConnect)
at com.mysql.jdbc.ConnectionProperties.<clinit>(MysqlConnect)
at java.lang.Class.initializeClass(MysqlConnect)
at java.lang.Class.initializeClass(MysqlConnect)
at com.mysql.jdbc.NonRegisteringDriver.connect(MysqlConnect)
at java.sql.DriverManager.getConnection(MysqlConnect)
at testsql.TestConnection.getConnection(MysqlConnect)
at testsql.TestConnection.execQuery(MysqlConnect)
at testsql.TestConnection.main(MysqlConnect)
Caused by: java.lang.ClassNotFoundException: javax.naming.StringRefAddr not
found in gnu.gcj.runtime.SystemClassLoader{urls=[file:./],
parent=gnu.gcj.runtime.ExtensionClassLoader{urls=[], parent=null}}
at java.net.URLClassLoader.findClass(MysqlConnect)
at java.lang.ClassLoader.loadClass(MysqlConnect)
at java.lang.ClassLoader.loadClass(MysqlConnect)
at java.lang.Class.initializeClass(MysqlConnect)
...11 more
ldd MysqlConnect
linux-gate.so.1 => (0xffffe000)
libgcc_s.so.1 => /lib/libgcc_s.so.1 (0xb7fdf000)
libm.so.6 => /lib/i686/libm.so.6 (0xb7fb9000)
libpthread.so.0 => /lib/i686/libpthread.so.0 (0xb7fa1000)
librt.so.1 => /lib/i686/librt.so.1 (0xb7f98000)
libz.so.1 => /lib/libz.so.1 (0xb7f84000)
libdl.so.2 => /lib/libdl.so.2 (0xb7f80000)
libc.so.6 => /lib/i686/libc.so.6 (0xb7e31000)
/lib/ld-linux.so.2 (0xb7ffc000)
-------*-------
TEST 1)
-------*-------
1) gcj -O2 -c mysql-connector-java-5.0.8-bin.jar -o mysql-5.0.8.o
-findirect-dispatch
2) gcj -O2 -shared mysql-5.0.8.o -o mysql-5.0.8.so
3) gcj -O2 --main=MysqlConnect MysqlConnect.class mysql-5.0.8.so -o
MysqlConnect -static-libgcj
(here i use mysql-5.0.8.so instead of mysql-5.0.8.o)
4) ./MysqlConnect
libgcj failure: gcj linkage error.
Incorrect library ABI version detected. Aborting.
ldd MysqlConnect
linux-gate.so.1 => (0xffffe000)
mysql-5.0.8.so => /usr/lib/mysql-5.0.8.so (0xb7e82000)
libgcc_s.so.1 => /lib/libgcc_s.so.1 (0xb7e74000)
libm.so.6 => /lib/i686/libm.so.6 (0xb7e4e000)
libpthread.so.0 => /lib/i686/libpthread.so.0 (0xb7e36000)
librt.so.1 => /lib/i686/librt.so.1 (0xb7e2d000)
libz.so.1 => /lib/libz.so.1 (0xb7e19000)
libdl.so.2 => /lib/libdl.so.2 (0xb7e14000)
libc.so.6 => /lib/i686/libc.so.6 (0xb7cc6000)
libgcj.so.9 => /usr/lib/libgcj.so.9 (0xb5d86000)
/lib/ld-linux.so.2 (0xb80d1000)
-------*-------
COMMENTS
-------*-------
The class file i generated in windows with jdk 1.5
"C:\Archivos de programa\Java\jdk1.5.0_16\bin\javac.exe" MysqlConnect.java
Thanks to all again...
--
View this message in context: http://www.nabble.com/Mysql-and--static--libgcj-tp19673573p19673573.html
Sent from the gcc - java mailing list archive at Nabble.com.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Mysql and -static--libgcj
@ 2008-09-26 3:26 ` Taufik Chowi
2008-09-26 3:35 ` ezer
0 siblings, 1 reply; 4+ messages in thread
From: Taufik Chowi @ 2008-09-26 3:26 UTC (permalink / raw)
To: ezer; +Cc: java
Dear Ezer,
i tried compiling your code, and it works perfectly no problem from Windows
i commented this code because i am so lazy to create new record in this table >.<
//Vector row = new Vector();
//row.add(rs.getInt("id"));
//row.add(rs.getString("titulo"));
//row.add(rs.getString("descripcion"));
D:\gcc-4.3\bin>gcj -O2 mysql-connector-java-3.0.17-ga-bin.jar MysqlConnect.java --main=MysqlConnect -static-libgcj
D:\gcc-4.3\bin>a
MySQL Connect Example.
Connected to the database
Query executed
Disconnected from database
Execution Time: 0 seconds
last time i also had the same NoClassDefFoundError problem, but usually everything will be ok if you added
private static final Class class3 = com.mysql.jdbc.Driver.class;//This will not compile with jde in my past experience , only include this to solve some of the NoClassDefFoundError from gcj
Cheers and God Bless,
Chowi
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Mysql and -static--libgcj
2008-09-26 3:26 ` Taufik Chowi
@ 2008-09-26 3:35 ` ezer
0 siblings, 0 replies; 4+ messages in thread
From: ezer @ 2008-09-26 3:35 UTC (permalink / raw)
To: java
Oh thanks for the time. i also see that for you its run fast. Without linking
static i have a delay in the run of 10 seconds..
Can you tell me 2 thinks.
1) How do you installed that version in windows.. i tryed with Java Native
compile, Mingw etc.. without succes.
2) can you generate linux exec with that windows version ?
I will try to install that version exactly as you indicate to me..
Thanks you a lot....
Taufik Chowi wrote:
>
> Dear Ezer,
>
> i tried compiling your code, and it works perfectly no problem from
> Windows
> i commented this code because i am so lazy to create new record in this
> table >.<
> //Vector row = new Vector();
> //row.add(rs.getInt("id"));
> //row.add(rs.getString("titulo"));
> //row.add(rs.getString("descripcion"));
>
>
> D:\gcc-4.3\bin>gcj -O2 mysql-connector-java-3.0.17-ga-bin.jar
> MysqlConnect.java --main=MysqlConnect -static-libgcj
> D:\gcc-4.3\bin>a
> MySQL Connect Example.
> Connected to the database
> Query executed
> Disconnected from database
> Execution Time: 0 seconds
>
>
>
>
> last time i also had the same NoClassDefFoundError problem, but usually
> everything will be ok if you added
> private static final Class class3 = com.mysql.jdbc.Driver.class;//This
> will not compile with jde in my past experience , only include this to
> solve some of the NoClassDefFoundError from gcj
>
>
> Cheers and God Bless,
>
> Chowi
>
>
>
>
>
--
View this message in context: http://www.nabble.com/Mysql-and--static--libgcj-tp19673573p19681963.html
Sent from the gcc - java mailing list archive at Nabble.com.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Mysql and -static--libgcj
@ 2008-09-26 3:57 Taufik Chowi
0 siblings, 0 replies; 4+ messages in thread
From: Taufik Chowi @ 2008-09-26 3:57 UTC (permalink / raw)
To: ezer; +Cc: java
Dear Ezer,
ok this time i will compile it with my linux server.
it runs on fedora core 4 (quite old) >.<
i cant run using -static-libgcj because my gcj version is too old i think (i am not sure too, because i am quite new with gcj)
# gcj -O2 mysql-connector-java-3.0.17-ga-bin.jar MysqlConnect.java --main=MysqlConnect -static-libgcj
gcj: unrecognized option '-static-libgcj'
instead i used this
# gcj -O2 mysql-connector-java-3.0.17-ga-bin.jar MysqlConnect.java --main=MysqlConnect -findirect-dispatch
# ./a.out
MySQL Connect Example.
Connected to the database
Query executed
Disconnected from database
Execution Time: 0 seconds
delay of 10 seconds?!?!?! are you saying that you've got output "Execution Time: 10 seconds" ??
that is crazy.. i have never seen one myself (though my experience with gcj is still a bit short ^^)
here is my gcj --version for linux
# gcj --version
gcj (GCC) 4.0.0 20050519 (Red Hat 4.0.0-8)
Copyright (C) 2005 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# mysql --version
mysql Ver 14.7 Distrib 4.1.11, for redhat-linux-gnu (i386)
@first question
my windows version? i can use it without having to install mingw or anything like that
http://www.thisiscool.com/gcc_mingw.htm
i downloaded this one http://static.thisiscool.com/gcc/gcc43-20061204.tar.bz2
extract and use it ^^; no setup (if the memory serves me right)
@second question
hmmm, you know i have read it somewhere , i think it is called native cross compiler or anything like that, it allows you compile a native code for another Operating System
but as you may have guessed, i havent tried it >.< , i think it is kinda like high level stuff or anything like that , since i am really confused reading the article :( (or perhaps it is only me)
Cheers and God Bless,
Chowi
----- Original Message ----
From: ezer <andres.a@adinet.com.uy>
To: java@gcc.gnu.org
Sent: Friday, September 26, 2008 10:34:37 AM
Subject: Re: Mysql and -static--libgcj
Oh thanks for the time. i also see that for you its run fast. Without linking
static i have a delay in the run of 10 seconds..
Can you tell me 2 thinks.
1) How do you installed that version in windows.. i tryed with Java Native
compile, Mingw etc.. without succes.
2) can you generate linux exec with that windows version ?
I will try to install that version exactly as you indicate to me..
Thanks you a lot....
Taufik Chowi wrote:
>
> Dear Ezer,
>
> i tried compiling your code, and it works perfectly no problem from
> Windows
> i commented this code because i am so lazy to create new record in this
> table >.<
> //Vector row = new Vector();
> //row.add(rs.getInt("id"));
> //row.add(rs.getString("titulo"));
> //row.add(rs.getString("descripcion"));
>
>
> D:\gcc-4.3\bin>gcj -O2 mysql-connector-java-3.0.17-ga-bin.jar
> MysqlConnect.java --main=MysqlConnect -static-libgcj
> D:\gcc-4.3\bin>a
> MySQL Connect Example.
> Connected to the database
> Query executed
> Disconnected from database
> Execution Time: 0 seconds
>
>
>
>
> last time i also had the same NoClassDefFoundError problem, but usually
> everything will be ok if you added
> private static final Class class3 = com.mysql.jdbc.Driver.class;//This
> will not compile with jde in my past experience , only include this to
> solve some of the NoClassDefFoundError from gcj
>
>
> Cheers and God Bless,
>
> Chowi
>
>
>
>
>
--
View this message in context: http://www.nabble.com/Mysql-and--static--libgcj-tp19673573p19681963.html
Sent from the gcc - java mailing list archive at Nabble.com.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2008-09-26 3:57 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-09-25 16:42 Mysql and -static--libgcj ezer
2008-09-26 3:26 ` Taufik Chowi
2008-09-26 3:35 ` ezer
2008-09-26 3:57 Taufik Chowi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).