Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

JAVA PACKAGE RUNTIME ERROR

 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Hi,

After surfing the World Wide Web, i got very little. It seems this is the only play where i can get help

Here is the problem :

I have a java program :
package com.system33.model;
import java.sql.*;
public class MyOracleConnection {
public Connection connectionDriver() {
Connection conn=null;
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
conn = DriverManager.getConnection("jdbc racle:thin:@localhost:1521:XE", "system","administrator");
} catch (Exception e) {
e.printStackTrace();
}
System.out.println(" "+conn);
return conn;
}
public String fetchData() {
String result="test";
try {
MyOracleConnection obj = new MyOracleConnection();
Connection c=obj.connectionDriver();
Statement stmt = c.createStatement();
String query="select * from boaiw";
ResultSet rs = stmt.executeQuery(query);
while(rs.next()) {
System.out.println(rs.getString(1));
result=rs.getString(1);
}
} catch (Exception e) {
e.printStackTrace();
}
return result;
}
public static void main(String[] args) {
MyOracleConnection obj=new MyOracleConnection();
System.out.println(obj.fetchData());
}
}


And i am usign this to get a connection with the database from a servlet,

the directory structure is :
C:\My Projects\BoaIntegratedWorkflow>java MyOracleConnection

It compiles fine,

but when i try to execute it the unwanted thing happens,

Exception in thread "main" java.lang.NoClassDefFoundError: MyOracleConnection (wrong name: com/system33/model/MyOracleConnection)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$000(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)


this is no less than BLUE SCREEN OF DEATH for me.

It works fine and fetches data if i drop package declararion/defination at the begining..



PLEASE HELP ME...PLEASE HELP ME....PLEASE HELP ME...

This is my last hope, or i have to move to COBOL, ha ha
 
Don't play dumb with me! But you can try this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
    Bookmark Topic Watch Topic
  • New Topic