English 中文(简体)
“java.lang.Class NotFoundException”
原标题:"java.lang.ClassNotFoundException" when executing Java code

I get a java.lang.ClassNotFoundException, when I execute the below code. Could someone explain me why I am facing this? All I need to do is to connect to the db and fetch some values from it. Is it a problem with the eclipse that I use?

import java.sql.*;

public class test_sample {

    public static void main(String[] args) {
        try {
              System.out.println("Test1");
              DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());

              Class.forName("oracle.jdbc.OracleDriver");
                  System.out.println("Test2");
              Connection con = DriverManager.getConnection(
              "jdbc:oracle:thin:@ussbazudb126.ussb.winson.net:1521/epdev", "manager", "<<PASSWORD>>");
              System.out.println("Test3");
             // Statement st = con.createStatement();
              PreparedStatement meta = con.prepareStatement("select project from isac_extract");
              System.out.println("Test4");
              ResultSet rset = meta.executeQuery();
              while (rset.next()) {
                  String project = rset.getString(1);
                  System.out.println(project);}
              }
              catch (Exception e){
                  e.printStackTrace();
                  }
              finally {System.out.println("Final Block");}

    }

}
最佳回答

Download appropriate Oracle JDBC driver from here. If you are using Eclipse you need to add ojdbc14.jar which contains the OracleDriver class to your build path. It is usually located in: {ORACLE DRIVER INSTALL PATH}jdbclibojdbc14.jar

如果你不使用国际民主和选举援助学会的话,你需要将联合分析小组的路子添加到你的舱位选择中。

问题回答

Go to Project nature (Project -> Property) -> Java Building Path -> Libraries -> Add external JARs -> selected jar with Degradingeur from You filesystem (You candown it from ,如果你有线的话。 这应当有所帮助。

很可能有: <密码>>oracle.jdbc. Oracleard/index>从您的班次中消失,检查结果。

将Oracle JDBC司机列入你的班次。

For Oracle 11g, you need to place ojdbc6.jar in Java Classpath. The ojdbc.jar can be found on Oracle home directory E:appshyamproduct11.2.0dbhome_1jdbclib. We can simply put ojdbc6.jar in C:Program FilesJavajre7libext directory instead of defining Java Classpath also.





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签