How to compile java class to native code by gcj, which connects to the database with JDBC
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Fang_Jing
Posted On:   Sunday, April 28, 2002 06:36 PM

I am trying to use gcj to compile my java program to native code, which trys to connect to the oracle database by JDBC. My gcj version is 2.96, and my Linux version is Red Hat 7.2. when I send the order: gcj --main=test.TestDb -o TestDb test.jar the following error occurs: java/lang/Class.java: In class `test.TestDb': java/lang/Class.java: In method `main(java.lang.String[])': java/lang/Class.java:0: bad class index 0 Would you please tell me how to fix these problem? Thank you very much The program is as the following: package test; /** * Title: * Description: * Copyright: Copyright (c) 2   More>>

I am trying to use gcj to compile my java program to native code, which
trys to connect to the oracle database by JDBC.
My gcj version is 2.96, and my Linux version is Red Hat 7.2.

when I send the order:
gcj --main=test.TestDb -o TestDb test.jar

the following error occurs:

java/lang/Class.java: In class `test.TestDb':
java/lang/Class.java: In method `main(java.lang.String[])':
java/lang/Class.java:0: bad class index 0


Would you please tell me how to fix these problem?
Thank you very much


The program is as the following:

package test;

/**
* Title:
* Description:
* Copyright: Copyright (c) 2002
* Company:
* @author
* @version 1.0
*/



/**
* Title: Mr.
* Description:
* Copyright: Copyright (c) 2001
* Company: CNNB
* @author Fang Jing
* @version 1.0
*/


import java.sql.*;
public class TestDb{


public static void main(String args[]){
String sDBDriver = "oracle.jdbc.driver.OracleDriver";
//String sDBDriver = "com.inet.tds.TdsDriver";
//String url
="jdbc:inetdae:202.101.189.18?database=ourbook&sql7=true&useUnicode=true&cha
racterEncoding=ISO-8859-1";// use your hostname and port number here
String url="jdbc:oracle:oci8:@abc";
String user = "abc"; // use your login here
String pwd = "abc321"; // use your password here

String sql="select * from netflow";
Connection conn = null;
Statement s=null;
ResultSet rs = null;
try {

// DriverManager.registerDriver( new
oracle.jdbc.driver.OracleDriver());

//Class.forName(sDBDriver).newInstance();
Class.forName(sDBDriver);

}
catch(Exception e) {
System.out.println("dberorr123");
}


try{
conn=DriverManager.getConnection(url,user,pwd);
s=conn.createStatement();
rs=s.executeQuery(sql);
while(rs.next()) {
// System.out.println("Óû§Ãû: < <"+rs.getString("bgr")+">> µãÊý
:"+rs.getString("sm"));
}
rs.close();
s.close();
conn.close();
}catch(SQLException e){
System.out.println("cxerorr");
e.printStackTrace();
}


}



}

   <<Less
About | Sitemap | Contact