Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Servlet and database issue in IDE

 
tom davies
Ranch Hand
Posts: 168
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I know previously people told me not to use the database with the servlet, but its part of a set of a piece of work i have been set, so i have no choice about that.
I have a form which submits an ID, i then get this ID using my servlet and feed it into an operations method i have to delete a student with the supplied ID.
I have made a tester class separate from my servlet that i use to add, delete and display the students to check my operations methods are working and i am connecting with the database.
This class works fine. When i use the code below in my servlet, which uses the method in the same way that i have tested it gives me an error. In the browser i get no error, it just shows me a blank page. When i look at the console output it says
INFO: SQLExceptionjava.sql.SQLException: No suitable driver found for jdbc:mysql://localhost:3306/university

Maybe i should add that i am using a MySQL database and a glassfish server both set up on my computer. I don't understand how it works fine on its own but throws a no suitable driver found error when i use it within my servlet?

Servlet is below
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64843
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Where did you put the driver jar file?
 
tom davies
Ranch Hand
Posts: 168
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
.jar file is in a folder called lib in my main project folder. I then right click on libraries in my IDE and add the jar, it creates the classpath for me. This has worked in the past for me, i had just assumed it would work in the same way with servlets.
 
tom davies
Ranch Hand
Posts: 168
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well it is clear now i have to add the classpath to the server, according to the netbeans documentation, it should do this automatically if a checkbox is ticked, which i already have. So i don't know why it is not recognising it still.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic