aspose file tools*
The moose likes JSP and the fly likes  to retreive datas from mysql table in jsp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark " to retreive datas from mysql table in jsp" Watch " to retreive datas from mysql table in jsp" New topic
Author

to retreive datas from mysql table in jsp

preethi Ayyappan
Ranch Hand

Joined: Oct 04, 2007
Posts: 518
Hi,
I am trying to put a combo box using jsp and i want to retreive the datas from my sql table and display those inside combobox.I have tried the below code.but it displays nothing inside combobox.

please help me to solve this.

Thanks.
[ April 10, 2008: Message edited by: preethi Ayyappan ]
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42635
    
  65
The code doesn't add any <option> elements, not does it properly close the <select> element.


Ping & DNS - my free Android networking tools app
preethi Ayyappan
Ranch Hand

Joined: Oct 04, 2007
Posts: 518

Is this code correct.But it is also not working.
Balasubramani Dharmalingam
Ranch Hand

Joined: Dec 06, 2004
Posts: 116
I think you are getting some exception and suppressing the same.Please add the following code inside the catch block in your JSP and confirm there is no any exception in executing the query.



Balasubramani SD,<br />SCJP 1.4,SCWCD 1.4,SCJP 5.0<br /><a href="http://sd.balasubramani.googlepages.com" target="_blank" rel="nofollow">www.sd.balasubramani.googlepages.com</a>
preethi Ayyappan
Ranch Hand

Joined: Oct 04, 2007
Posts: 518
I have put that in catch and tried.But it is not displaying any exception error.still showing the same combobox with no values.I am having the database conference,meetme table and datas in field location.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42635
    
  65
Does the query actually retrieve any records?
preethi Ayyappan
Ranch Hand

Joined: Oct 04, 2007
Posts: 518
I dont understand ulf.how shall i check whether it is retreiving records?i am having records in the field location.Am i wrong in the code to retreive the datas?
Balasubramani Dharmalingam
Ranch Hand

Joined: Dec 06, 2004
Posts: 116
Add the following bolded line in your code. If you get "Values: true" in your JSP then you are getting data from table else you are not.

preethi Ayyappan
Ranch Hand

Joined: Oct 04, 2007
Posts: 518
i have added that lines too.i didnt get anything.could you please guide me how to solve this?where i am wrong?why the datas are not retreived?
[ April 10, 2008: Message edited by: preethi Ayyappan ]
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42635
    
  65
I'd run the query directly against the database, using the DB's tools, or a generic JDBC GUI client like Squirrel.
preethi Ayyappan
Ranch Hand

Joined: Oct 04, 2007
Posts: 518
sorry.i dont understand what you are saying
Muhammad Saifuddin
Ranch Hand

Joined: Dec 06, 2005
Posts: 1321

means, to check your connection and data retrieval code with simple java file.


Saifuddin..
[Blog][Linkedin] How To Ask Questions On JavaRanch My OpenSource
preethi Ayyappan
Ranch Hand

Joined: Oct 04, 2007
Posts: 518
I have just tried to insert some values to the test table in database conference.but this is also not working.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42635
    
  65
As was pointed out to you above, this is a really bad idea:

You must perform proper exception handling in JDBC code.

Why are you putting apostrophes before and behind table and column names? Are you sure the database can handle that?
preethi Ayyappan
Ranch Hand

Joined: Oct 04, 2007
Posts: 518
sorry.now i have put printstacktrace inside catch statement.now i am getting the following error:

java.lang.ClassNotFoundException: com.mysql.jdbc.Driver at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1363) at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1209) at org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:125) at org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:63) at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:169) at org.apache.jsp.database_jsp._jspService(database_jsp.java:53) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98) at javax.servlet.http.HttpServlet.service(HttpServlet.java:803) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:331) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265) at javax.servlet.http.HttpServlet.service(HttpServlet.java:803) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:174) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:174) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:874) at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665) at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528) at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81) at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689) at java.lang.Thread.run(Thread.java:619)
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42635
    
  65
Do you have the jar file containing the JDBC driver in the WEB-INF/lib directory of your web application?
preethi Ayyappan
Ranch Hand

Joined: Oct 04, 2007
Posts: 518
Just now i put mysql jar file inside the lib directory.whether i have to set path for it?
preethi Ayyappan
Ranch Hand

Joined: Oct 04, 2007
Posts: 518
Thankyou all.now its working.
 
Consider Paul's rocket mass heater.
 
subject: to retreive datas from mysql table in jsp