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.
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.
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.
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.
posted 6 years ago
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.
posted 6 years ago
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.