What's wrong with following code.tryuing to access MS access using JSP

i've cerated a database names TiH.mdb which has a table named TBL_TBL_FUNCTIONS
in the table there r thrree fields
BUS_FUN_ID,BUS_FUN_NAME,FUN_ID

now i 've just written the following code to access data from the table
but nothing gets displayed
what's wrong with the code??

<html>
<head>
<%@ page
      import = "java.io.*"
      import = "java.lang.*"
      import = "java.sql.*"
%>
<title>
Test
</title>
</head>
<body>
<h1>test</h1>
<% out.println("hello1");
      String      place;
      Connection dbconn;
      ResultSet results;
      PreparedStatement sql;
      int bus_fun_id,fun_id,name;
      String database = "jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=

E:\Tools\Tomcat\webapps\examples\TiH\TiH.mdb";
      dbconn = DriverManager.getConnection(database);
      sql = dbconn.prepareStatement("SELECT * FROM TBL_FUNCTIONS");
      results = sql.executeQuery();
      while(results.next())
            {
                  bus_fun_id = results.getInt("BUS_FUN_ID");
                        fun_id = results.getInt("FUN_ID");
                        name = results.getInt("BUS_FUN_NAME");
                        out.println(bus_fun_id);
                  out.println(fun_id);
                  out.println(name);
            }
      %>
</body>
</html>




Kindly help
LVL 8
hiteshgupta1Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

 
avinthmCommented:
Make sure it is able to connect to your database and are there any records in your table ?

And change the import to
<%@ page import="java.io.*,java.lang.*,java.sql.*" %>
0
 
hiteshgupta1Author Commented:
Thanx for ur help

now i m getting following error
Error: 500
Location: /examples/TiH/Temp.jsp
Internal Servlet Error:

javax.servlet.ServletException: [Microsoft][ODBC Microsoft Access Driver] Could not find file '(unknown)'.
      at org.apache.jasper.runtime.PageContextImpl.handlePageException(Unknown Source)
      at TiH.Temp_1._jspService(Temp_1.java:89)
      at org.apache.jasper.runtime.HttpJspBase.service(Unknown Source)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java)
      at org.apache.tomcat.facade.ServletHandler.doService(Unknown Source)
      at org.apache.tomcat.core.Handler.invoke(Unknown Source)
      at org.apache.tomcat.core.Handler.service(Unknown Source)
      at org.apache.tomcat.facade.ServletHandler.service(Unknown Source)
      at org.apache.tomcat.core.ContextManager.internalService(Unknown Source)
      at org.apache.tomcat.core.ContextManager.service(Unknown Source)
      at org.apache.tomcat.modules.server.Http10Interceptor.processConnection(Unknown Source)
      at org.apache.tomcat.util.net.TcpWorkerThread.runIt(Unknown Source)
      at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(Unknown Source)
      at java.lang.Thread.run(Thread.java:536)

0
 
avinthmCommented:
its not able to find the .mdb file.
try to give relative path of your .mdb file, avoid giving absolute path.
you should change the path to E:/Tools/Tomcat/webapps/examples/TiH/TiH.mdb
and make sure TiH.mdb is in specified path
0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
TimYatesCommented:
Change:

    String database = "jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=

E:\Tools\Tomcat\webapps\examples\TiH\TiH.mdb";

to

    String database = "jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=E:\\Tools\\Tomcat\\webapps\\examples\\TiH\\TiH.mdb";

And consider not using Access... ;-)

Tim
0

Experts Exchange Solution brought to you by ConnectWise

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
 
borislavmarkovCommented:
you should close you connections and resources ath the end of  jsp :)
0
 
hiteshgupta1Author Commented:
definately sir:)
i'll take care of it!!
0
 
avinthmCommented:
what was wrong with my solution ?
infact it works fine.
0
 
hiteshgupta1Author Commented:
avinthm thanx for ur help
actaul rpoblem was with the format in which i was pcefying the path
u said u should write comlete path "e:\tools\tomcat...)
but that didn't solved the problem
the corrcect solution was to write path as "E:\\tools\\tomcat....) ,means i have to use double slashes instead of single


once again thanx for ur concern and sorry too as i could not divide points between two ppl
0
 
avinthmCommented:
> u said u should write comlete path "e:\tools\tomcat...)
i think u got my point wrong. i asked u to change the path....i have specified forward slash (/) instead of backward slash (\).

Anyway, your problem is solved. Thats more important than points. :)

cheers
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.