Exception in thread "main" java.lang.NoClassDefFoundError: sqlj/tools/Sqlj
程序中有异常跑出 NoClassDefFoundError 用TRY{} 捕捉是JAVA程序问题
程序中有异常跑出 NoClassDefFoundError 用TRY{} 捕捉是JAVA程序问题
解决方案 »
- 新手REDHAT7+ ORACLE10G安装求教..
- 求教——用SQL 或 触发器实现在数据表一列中统一追加相同的内容!!!
- oracle存储过程:多表连接计算求出债权债务表汇总及发生年限!(有测试数据,高手入!)
- 我在pl/sql里用order by排序1个字段没问题,但是写到我的程序里顺序就乱了
- oracle9i精简版登陆提示“ORA-01017:invalidusername/password;logondenied”
- 如何使用标准SQL语句查询数据表中的第一条记录??
- 关于timesten 连接
- Oracle不可用怎么解决?
- 求一sql或其他方法
- 要对两个表中 有交集的记录都删除。应该如何处理,谢谢!
- java.sql.SQLException ORA-04031
- 大家来讨论一下如何用JAVA写ORACLE存储过程,不只是调用
如果用命令帮助sqlj -help也会出现同样的错误。
/**
* Program Name: TokSequence.java
*/import java.util.*;public class TokSequence {
private StringTokenizer tk;
public TokSequence(StringTokenizer tk1) {
tk = tk1;
}
public int getInt() {
int n = Integer.valueOf(tk.nextToken()).intValue();
return n;
}
public double getDouble() {
double d = Double.valueOf(tk.nextToken()).doubleValue();
return d;
}
public String getString() {
return tk.nextToken();
}
}/**
* Program Name: AcctsForProjs.sqlj
*/
import java.io.*;
import java.util.*;
import java.sql.SQLException;
import oracle.sqlj.runtime.Oracle;#sql iterator DnoAno(int departmentno, int accountno);class AcctsForProjs {
private BufferedReader input;
private DonAno aDnoAno;
public AcctsForProjs() {
connectDB();
openInput();
}
private void runAcctsForProjs() {
int accountno, departmentno, projectno;
String line;
try {
while(true) {
System.out.println("Please enter a project number" +
" (enter a -1 to terminate) >>");
line = input.readLine();
projectno = getProjectno(line);
if(projectno == -1) {
System.out.println ("Bye");
System.exit(1);
}
if(select(projectno) == 0) {
while(aDnoAno.next()) {
System.out.println("Account number = " +
aDnoAno.accountno() + "Department number = " +
aDnoAno.departmentno() );
}
}
closeIter(aDnoAno);
}
} catch(IOException e) {
System.err.println("Error reading input.\n" + e);
closeInput();
System.exit(1);
} catch(SQLException e) {
System.err.println("Error getting data from iterator.\n" + e);
closeInput();
System.exit(1);
}
}
private void connectDB() {
try {
Oracle.connect(getClass(), "connect.properties");
} catch(SQLException e) {
System.err.println("Error connecting to database.\n" + e);
System.exit(1);
}
}
private void openInput() {
input = new BufferedReader(new InputStreamReader(System.in));
}
private int getProjectno(String line) {
StringTokenizer tk = new StringTokenizer(line);
TokSequence g = new TokSequence(tk);
return g.getInt();
}
private int select(int projectno) {
try {
#sql
aDnoAno = {SELECT accountno, departmentno FROM ACCOUNT_LIST
WHERE projectno = :projectno
};
return 0;
} catch(SQLException e) {
System.err.println("Cannot execute SELECT statement./n" + e);
return -1;
}
}
private void closeIter(DnoAno aDnoAno) {
try {
aDnoAno.close();
} catch(SQLException e) {
System.err.println("Cannot close iterator.\n" + e.toString());
closeInput();
System.exit(1);
}
}
private void closeInput() {
try {
input.close();
} catch(IOException e) {
System.err.println("Cannot close buffered stream.\n" + e.toString());
System.exit(1);
}
}
public static void main(String[] args) {
AcctsForProjs maincode = new AcctsForProjs();
maincode.runAcctsForProjs();
}
}
sqlj AcctsForProjs.sqlj TokSequence.java
你这命令是在哪儿执行的呀,JAVA东东发布给ORACLE了没呀?猫咪有点糊涂
把相应的类文件放到你的class-path下
Configure your environment as follows: We assume that SQLJ has been installed with the Oracle installer. Let ORACLE_HOME be the location into which your Oracle products have been installed.
Verify your JDBC installation before using SQLJ. Refer to the section "Getting Started" in the book SQLJ Developer's Guide and Reference Oracle 9i Release 1 (9.0.1) for information on testing your SQLJ and JDBC installations. (Note: You must be signed up for the Oracle Technology Network at http://technet.oracle.com in order to access the online documentation.)
Specifically, in order to use SQLJ you must have ORACLE_HOME/jdbc/lib/classesxxx.zip in your CLASSPATH environment variable (where xxx is either 111 or 12, depending on the version of your Java compiler). Additionally -depending on the nature of your JDBC driver- dynamic link libraries may have to be installed. Ensure that the directory ORACLE_HOME/bin is included in your environment variable PATH.
You must add the files ORACLE_HOME/sqlj/lib/translator.zip and one of the ORACLE_HOME/sqlj/lib/runtimexxx.zip libraries. to the environment variable CLASSPATH.
If you use JDK 1.1.x and Oracle JDBC 9.0.1 use runtime11.zip. If you use JDK 1.2 or later and Oracle JDBC 9.0.1 use runtime12.zip. You can uso use runtime12ee.zip if you have a J2EE environment.
If you use an Oracle JDBC driver version prior to JDBC 9.0.1 use runtime.zip.
If you do not have an Oracle JDBC driver in your environment use runtime-nonoracle.zip. IMPORTANT! Earlier SQLJ releases only required that you place translator.zip in the CLASSPATH in order to translate and/or run SQLJ programs.
SQLJ versions 8.1.7 and later require additionally one of the runtime zip files (runtime.zip, runtime11.zip, or runtime12.zip) in your CLASSPATH in order to translate SQLJ programs.
This completes the installation.