如何在Linux下用gcj编译 与数据库连接的程序 (10分)

  • 主题发起人 主题发起人 fangj
  • 开始时间 开始时间
F

fangj

Unregistered / Unconfirmed
GUEST, unregistred user!
我想用gcj编译我的java程序,该程序通过jdbc连接oracle数据库
我的gcj version 是 2.96, 我的linux version 是 Red Hat 7.2.
当我发送命令时:
gcj --main=test.TestDb -o TestDb test.jar
出现以下错误
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
请问怎样解决以上问题?
十分感谢!
程序代码如下:
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();
}

}

}

 
后退
顶部