Skip to Main Content

Java Database Connectivity (JDBC)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver

504701Apr 6 2006 — edited Feb 25 2011
I must apoligise for this age old query in advance.
If this post in not in the right place, again i must apoligise.

Been using java for a while now expecially with netbeans. Recently started executing the jar files created by netbeans.

My jar file holds quite a simple application-> to execute an insert on a particular table within my oracle db. [This application Runs perfectly through NetBeans].
I want to run this jar file from the command prompt using the java -jar [option].

When i run the jar from the prompt i get this whole spiel(Story) from java:
java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver
C:\Documents and Settings\Owner\My Documents\Reciepts\BookClub\dist>java -jar Bo
okClub.jar
java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver
at java.net.URLClassLoader$1.run(URLClassLoader.java:199)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:187)
at java.lang.ClassLoader.loadClass(ClassLoader.java:289)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:274)
at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:141)
at bookclub.toDbms.<init>(toDbms.java:29)
at bookclub.Main.main(Main.java:32)
Press ANY key to execute

INSERT INTO Members(member_id, group_id, first_name, last_name, address, town, city, phone_code, phone_num) VALUES(16,30,'Maybe',Someone','Mount Street','Somewhere','Dublin','01','1234567')
java.lang.NullPointerException
at bookclub.toDbms.execute(toDbms.java:48)
at bookclub.Main.main(Main.java:46)
Press any key continue the application

I gather the null pointer exception is comming from the missing drivers!

My Details:

C:\Documents and Settings\Owner>echo %classpath%
c:\oracle\ora92\jdbc\lib\ojdbc14.jar

C:\Documents and Settings\Owner>java -version
java version "1.4.2_04"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_04-b05)
Java HotSpot(TM) Client VM (build 1.4.2_04-b05, mixed mode)

(all oracle driver classs .jar files are here)
Path=c:\j2sdk1.4.2_04\bin;c:\oracle\ora92\jdbc\lib;C:\oracle\ora92\bin;C:\Program Files\Oracle\jre\1.3.1\bin;C:\Program Files\Oracle\jre\1.1.8\bin;......

If anyone out there can point me in some sort of a direction with this one, be most gratefull.

DobSun [or [i]user501698]

Comments

KarK
Answer

Your query has syntax error apart from the logic:

Try the below:

select * from

(

select dept,sales,

--activemonth,

rtrim(to_char(activemonth,'Month')) as currentM,

length(rtrim(to_char(activemonth,'Month'))) as length1

from dateorder

)

pivot

(

  sum(sales) as total

  for currentM in ('March')

);

OUTPUT:

DEPT           LENGTH1 'March'_TOTAL

----------- ---------- -------------

Stationery           7

Books                8

Toys                 7

Toys                 8

Toys                 3

Stationery           4

China                7

Books                5         82.34

Books                7

Toys                 4

China                3

DEPT           LENGTH1 'March'_TOTAL

----------- ---------- -------------

Stationery           8

Stationery           3

13 rows selected.

Marked as Answer by user8167598 · Sep 27 2020
Partha Sarathy S

Try this.

select * from (

select dept,sales,

--activemonth,

rtrim(to_char(activemonth,'Month')) as currentM,

length(rtrim(to_char(activemonth,'Month'))) as length1

from dateorder)

pivot

(

  sum(sales) as total

  for currentM in ('March')

);


Don't know what you are trying to achieve, but it would be better to do like this.

select DEPT,

       LENGTH1,

       NVL("'March'_TOTAL",0)

from (

select dept,sales,

--activemonth,

rtrim(to_char(activemonth,'Month')) as currentM,

length(rtrim(to_char(activemonth,'Month'))) as length1

from dateorder)

pivot

(

  sum(sales) as total

  for currentM in ('March')

);

AnnEdmund

You mean this?

SELECT dept,

       SUM(DECODE(currentM,'March',sales)) Total,

       currentM

FROM(SELECT dept,

       sales,

       to_char(activemonth,'fmMonth') AS currentM

FROM DATEORDER)

WHERE currentM = 'March'

GROUP BY dept,currentM;


OUTPUT:-

DEPT         TOTAL CURRENTM

----------- ---------- ---------

Books        82.34 March
AnnEdmund

Like this with PIVOT? If this is not your requirement then tell your requirement and expected output

SELECT *

FROM(SELECT dept,

       sales,

       to_char(activemonth,'fmMonth') AS currentM

FROM DATEORDER)

PIVOT(SUM(sales) Total FOR currentM IN('March'))


OUTPUT:-

-------

DEPT    'March'_TOTAL

----------- -------------

Stationery

China

Books           82.34

Toys

user8167598

Thanks ! I should have gone to spec savers !

1 - 5
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Mar 25 2011
Added on Apr 6 2006
16 comments
33,462 views