• Post Reply 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

Can't get my JDBC DBConnection

 
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is the same exact code to connect me to the DB as another application I am using with all that changed is the Schema Uname/Pword. The other app works just fine but with the one I will paste below, it simply won't connect and I have no clue what the problem could be...
Also if you don't mind, in this same code, I am trying to persist data submitted in the JSP form into the database. Can you tell me if I got this right because I truly think I do but I am not sure. Either way my main issue is the DB connection.

Here is the Singleton DBConnection class.



___________________________________________________________________________

Here is the JSP that user enters into



___________________________________________________________________________________________

Here is the Servlet that Validates that form and sends data to be persisted to Database




____________________________________________________________________________________________

LAST ONE HERE: This is the DAO class that has the Persist() that will be called from the Servlet above.




Can anyone PLEASE help me, this is SO important right now to what I am working on. Just in general. I really need my DBConnection Up and running. Thank you all.
 
Jeremy McNally
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HERE IS THE SERVER LOG if it helps you.

 
Marshal
Posts: 25594
69
Eclipse IDE Firefox Browser MySQL Database
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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



ClassNotFoundException always means the class named isn't in the class path. You could put it in your application's WEB-INF/lib folder, or in whatever the right place is for Glassfish to make it available to all applications, but you haven't done either of those.
 
Paul Clapham
Marshal
Posts: 25594
69
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And please, please, use a PreparedStatement to insert records to that table. The security reason is that it prevents SQL injection attacks, and the immediate practical reason is that your statement will fail because you didn't escape the apostrophe correctly in the name of Doctor O'Brien.
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why did you post this in the "Meaningless Drivel" forum? Moving it to a more appropriate forum.
 
Jeremy McNally
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am new to this forum. This is a Java Forum and this is a Java Problem... That is why I posted it here. No need to review it if you don't wish to, I did figure it out for myself this morning anyway. Could you tell me what you mean by 'more appropriate forum'? That way I can distinguish which Java stuff goes where next time?? Thanks for your response.
 
Jeremy McNally
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For people who do read this and may need to know what my problem may have been:

- I didn't copy the OJDBC6.jar into the WEB-INF/lib folder as I only had it in my Java Resources Lib area... Needs to be in both places as far as I know but adding it there did help.

Hope this helps someone out down the road. These are the problems that you know all your code is correct and can't figure out where the issue lies. That is why UNLIKE ME last night, it is important to always read the logs.
 
Jeremy McNally
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
PAUL CLAPHAM: Thanks for your response about the Prepared Statement. I am not sure how to do that but I can figure it out... Would I create it in the Database with SQL or in my Java Program? Also thanks everyone else for your posts.
 
Paul Clapham
Marshal
Posts: 25594
69
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
PreparedStatement is a Java type just like Statement (which you used).
 
Try 100 things. 2 will work out, but you will never know in advance which 2. This tiny ad might be one:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic