Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Connecting to database in webservice project  RSS feed

 
Nagendra Shasthri
Ranch Hand
Posts: 35
Chrome Java MyEclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi...I am new to web service projects...can anybody help me how to connect to database?I mean what I have to write in SOAPImpl class to get connected to database...

I have written

Class.forName("com.mysql.jdbc.Driver");
con = DriverManager.getConnection("DBName","root", "root");
Statement st = con.createStatement();
ResultSet rs = st.executeQuery("Select PatientFName,Patient_ID,Age,Gender from patient");

It is throwing invocation target exception...
 
Stefan Evans
Bartender
Posts: 1836
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So which one of these lines is giving you the invocation target exception?

Is there any more to that exception error message? Look for a line that says "caused by..."

 
Nagendra Shasthri
Ranch Hand
Posts: 35
Chrome Java MyEclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It was giving exception at Driver.getConnection()...Now I installed DB in my system only....that issue is solved...Thank you Stefan..
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!