Mysql and -static--libgcj

ezer andres.a@adinet.com.uy
Thu Sep 25 16:42:00 GMT 2008


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.


More information about the Java mailing list

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