How to Connect JSP (Tomcat) with MS access Database

     ^
Hi all:
I have been trying to connect JSP using tomcat server with database in MS Access..I have been going through the required steps...but it seems it is a bit complicated...pls help.
ps: I used to get this message when I run the program:
C:\jakarta-tomcat-4.0-b5\work\localhost\feras\db1_jsp.java:71: Class org.apache.jsp.PreparedStatement not found.
     PreparedStatement sql;
     ^
C:\jakarta-tomcat-4.0-b5\work\localhost\feras\db1_jsp.java:81: Undefined variable or class name: DriverManager
               dbconn = DriverManager.getConnection(url);
               ^
C:\jakarta-tomcat-4.0-b5\work\localhost\feras\db1_jsp.java:111: Class org.apache.jsp.SQLException not found.
          catch (SQLException s)

Hi friends:
this is the source code, I am working on tomcat server, and it doesn't work at all
<html>
<head>
<%@ page
     import = "java.io.*"
     import = "java.lang.*"
     import = "java.sql.*"
%>
<title>
JSP Example 2
</title>
</head>
<body>
<h1>JSP Example 3</h1>
<%
     String     place;
     String url = "jdbc:odbc:ferasdb";
     Connection dbconn;
     ResultSet results;
     PreparedStatement sql;
     try
          Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
          try
               int     latitude,longitude,easting,northing;
               boolean     doneheading = false;
               dbconn = DriverManager.getConnection(url);
               place = request.getParameter("place");
               sql = dbconn.prepareStatement("SELECT * FROM gazetteer WHERE feature = '" + place + "'");
               results = sql.executeQuery();
               while(results.next())
                    if(! doneheading)
                         out.println("<table border=2>");
                         doneheading = true;
latitude = results.getInt("latitude");
longitude = results.getInt("longitude");
easting = results.getInt("easting");
northing = results.getInt("northing");
                    out.println("<tr><td>" + latitude);
                    out.println("<td>" + longitude);
                    out.println("<td>" + easting);
                    out.println("<td>" + northing);
               if(doneheading)
                    out.println("</table>");
               else
                    out.println("No matches for " + place);
          catch (SQLException s)
               out.println("SQL Error<br>");
     catch (ClassNotFoundException err)
          out.println("Class loading error");
%>
</body>
</html>

Similar Messages

  • How to connect Forms 6i with MS Access

    Dear All:
    Can we connect Forms 6i with MS Access? If yes then how? Any document? Any suggestions?
    Thanks
    Hassan

    Thanks Jose for your suggestions:
    I am sorry I did not use the search utility of Forum.
    Anyway I have connect the Forms 6i with MS Access
    I created two text item in a Non-Database block and write following coding on a Push Button:
    declare
    connection_id EXEC_SQL.CONNTYPE;
    cursorID EXEC_SQL.CURSTYPE;
    sqlstr VARCHAR2(1000);
    d1 VARCHAR2(100);
    d2 NUMBER;
    nIgn PLS_INTEGER;
    nRows PLS_INTEGER := 0;
    BEGIN
    connection_id := EXEC_SQL.OPEN_CONNECTION('hsn','hsn','odbc:test');
    cursorID := EXEC_SQL.OPEN_CURSOR(connection_id);
    sqlstr := 'select d1,d2 from abdali ';
    EXEC_SQL.PARSE(connection_id, cursorID, sqlstr, exec_sql.V7);
    EXEC_SQL.BIND_VARIABLE(connection_id, cursorID, '', '');
    EXEC_SQL.DEFINE_COLUMN(connection_id, cursorID, 1, d1, 100);
    EXEC_SQL.DEFINE_COLUMN(connection_id, cursorID, 2, d2, 100);
    nIgn := EXEC_SQL.EXECUTE(connection_id, cursorID);
    WHILE (EXEC_SQL.FETCH_ROWS(connection_id, cursorID) > 0 ) LOOP
    nRows := nRows + 1;
    EXEC_SQL.COLUMN_VALUE(connection_id, cursorID, 1, :d1);
    --EXEC_SQL.COLUMN_VALUE(connection_id, cursorID, 2, :d2);
    next_record;
    END LOOP;
    message(nrows);
    IF (nRows <= 0) THEN
    TEXT_IO.PUT_LINE ('Warning: query returned no rows');
    END IF;
    END;
    I can retrieve the data from MS Access but there is a problem occured.
    The data type of one column in Access is defined as Intiger
    I also defined a text item in form as Intiger but when retrieved then it returned following error:
    FRM-40735: WHEN-BUTTON-PRESSED trigger raised unhandled exception ORA-306500.
    I remarked the following coding it works fine.
    EXEC_SQL.COLUMN_VALUE(connection_id, cursorID, 2, :d2);
    Any suggestions: I also read the OCA_INFO.pdf but did not find how to handle this type of problem.
    If you can help me to find out how to match the data types of both the databases?
    Also can I insert the data from a Database Block of Oracle into MS-ACCESS thru write code on the Button.
    Thanks for help
    Hassan

  • I want to connect an applet with an access database

    I want to connect an applet with an access(*.mdb) database, how I do?
    I now the jdbc odbc bridge but how work it?
    Please Help me!!!!!!!!!!

    If you want access database please install IDSSERVER and import j102.sql.*;
    Example:
    import java.awt.*;
    import java.io.*;
    import j102.sql.*;
    public class AccessMdb extends Applets {
    Connection con;
    ResultSet rs;
    Statement stmt;
    IDSDriver drv;
    String _url ="jdbc:ids://localhost:your port /conn?dsn="your database"";
    // make connection to database
    drv = new j102.sql.IDSDriver();
    try{
    con = drv.connect(_url,null);
    stmt = con.createStatement();
    // query database
    stmt.executeQuery("your SQL statement");
    }catch(Exception ex){
    System.out.println(ex.getMessage());
    Good luck.

  • How to connect Developer 6i with third party Databases

    How to connect Developer 6i with third party Databases

    Hi,
    Oracle Forms 6i comes with a Oracle Client Adaptor, OCA, that allows you to connect to 3rd party databases. Starting Forms 9i you use gateways.
    Frank

  • How to link dataTable component with Microsoft Access Database?

    Please mail me @ [email protected]

    Creator might not support MS Access yet but use this code for an access database connection will always work even through notepad or textpad:
    import java.io.BufferedInputStream;
    import java.io.File;
    import java.io.FileInputStream;
    import java.io.InputStream;
    import java.util.Properties;
    * @author Mark Hennessy
    public class MyDataSource {
    private static MyDataSource ds = null;
    private static java.sql.Connection connection = null;
    /** Creates a new singleton instance of MyDataSource */
    private MyDataSource() {
    try{
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    connection = java.sql.DriverManager.getConnection("jdbc:odbc:<db name>", "guest", "guest");
    }catch(ClassNotFoundException cnf){
    cnf.printStackTrace();
    }catch(java.sql.SQLException sqle){
    sqle.printStackTrace();
    public static DataSource getInstance() {
    if(ds == null)
    ds = new DataSource();
    return ds;
    public java.sql.Connection getConnection() {
    return this.connection;
    public static void closeConnection() {
         try{
              connection.close();
         }catch(java.sql.SQLException sqle){
              sqle.printStackTrace();
    plus set up the ODBC connection via click start , click run and then copy and paste the following "odbcad32.exe" without the quotes, click ok, click user DSN tab, click Add...button select Microsoft Access Driver (*.mdb) click finish, give <db name> name of ur access database, give any description <whatever> or leave blank click the select... button navigate to the access database u want to connect to in your java code and select it.
    in calling program
    public class CustomersImplimentation {
    private static java.sql.Connection connection = null;
    private java.sql.ResultSet rs = null;
    public CustomersImplimentation(){
    connection = MyDataSource.getInstance().getConnection();
    public Customers[] findAll(){
    java.util.ArrayList list = new java.util.ArrayList();
    String sql = "SELECT * FROM CUSTOMERS";
    try{
    java.sql.Statement stmt = connection.createStatement();
    rs = stmt.executeQuery(sql);
    while(rs.next()){
    list.add(new Customers(rs.getInt(1), rs.getString(2), rs.getString(3)));
    }catch(java.sql.SQLException sqle) {
    System.out.println((new StringBuilder()).append(
    "SQLException :: executeQuery Cannot find all Customers:").append(sqle).toString());
    Customers[] customers = new Customers[list.size()];
    for(int i = 0; i < list.size(); i++){
    customers[i] = (Customers)list.get(i);
    return customers;
    if you have a Customers class created with set and get methods and a constructor that takes an int string string i.e.
    public Customers(int ID, String firstName, String lastName){}
    then u should be able to run these classes from within creator with an access database. hope this helps?
    regards
    Henno

  • How to connect  netbeans ide with ms access?

    hi,
    i am using netbeans ide (latest one) . I use new project option to create a new project.Then i use java desktop application option to create a java desktop application.Then i get an error unable to get schemas.
    Could anybody explain what this error is and how to solve this problem.
    Thanking you ,
    Mani.

    Netbeans related questions belong in netbeans forums.
    Alternatively look into JDBC
    Mel

  • How to connect my Macbook with an ipad mini in order to have an access to the internet on my iPad?

    Dear fellows, I am having a trouble in how to connect my mac with an iPad mini in order to have an access to the internet.

    If you are attempting to share your iPad mini's cellular data connection with the MacBook, please check out the following Apple Support article for additional details on how to do so.

  • How to connect jsp & ms-access

    hi,
    i need to retrive data from database.how to connect jsp & ms-access.i m using weblogic8.1.

    hi,
    i need to retrive data from database.how to connect jsp & ms-access.i m using weblogic8.1.

  • How to combinate JSP+Tomcat+mysql??

    Hi,guys. My question is as the above subject.
    I have installed JDK, Tomcat, mysql, and my OS is WinXP, I am trying to develop a JSP site in my computer.
    For JDK, the commands javac, java, ...... work OK;
    For Tomcat, http://localhost:8080 works OK, meaning the cat page appears.
    For mysql, I can login, and sql statements work OK;
    And I download mysql-connector-java-3.1.8a.
    What I should do further to combinate JSP+Tomcat+mysql, so my JSP site can work? Any advice?
    I need help.
    Thanks in advance!

    Thanks,duffymo!
    As you said, I am learning more about those things.
    Actually I am trying to open a JSP webpage to show the connection JSP+Tomcat+mysql works OK.
    I copied the mysql-connector-java-3.1.8-bin.jar to ...Tomcat 5.0\common\lib,
    created a datebase, named test in MySQL, and wrote a JSP as the below:
    <%@ page contentType="text/html; charset=gb2312" %>
    <%@ page language="java" %>
    <%@ page import="com.mysql.jdbc.Driver" %>
    <%@ page import="java.sql.*" %>
    <%
    //driver
    String driverName="com.mysql.jdbc.Driver";
    //username
    String userName="test";
    //code
    String userPasswd="123";
    //database
    String dbName="test";
    //table name
    String tableName="mytab";
    //connection string
    String url="jdbc:mysql://localhost/"+dbName+"?user="+userName+"&password="+userPasswd;
    Class.forName("com.mysql.jdbc.Driver").newInstance();
    Connection connection=DriverManager.getConnection(url);
    Statement statement = connection.createStatement();
    String sql="SELECT * FROM "+tableName;
    ResultSet rs = statement.executeQuery(sql);
    ResultSetMetaData rmeta = rs.getMetaData();
    int numColumns=rmeta.getColumnCount();
    // output
    out.print("id");
    out.print("|");
    out.print("num");
    out.print("<br>");
    while(rs.next()) {
    out.print(rs.getString(1)+" ");
    out.print("|");
    out.print(rs.getString(2));
    out.print("<br>");
    out.print("<br>");
    out.print("successful!");
    rs.close();
    statement.close();
    connection.close();
    %>
    How can I test the connection JSP+Tomcat+mysql works OK?
    Thanks again!

  • How to connect iPhone 5s with Mercedies GL command online

    How to connect iPhone 5s with new Mercedies GL s command online to access internet in Indian my service provider is Airtel  

    Ensure Bluetooth connection has been established for voice. On the iPhone ensure you've got personal hotspot enabled. On the GL Command system, go to online, and select your phone connection from the bottom left.
    Works with my GL 2013 model, my iPhone 5S and also the 5 from my wife. Works great in glorious 4G speeds on my Vodafone connection.

  • How to connect my ipad with mac using bluetooth?

    how to connect my ipad with mac using bluetooth?

    You can't so quit trying. Take a look at this to see what is supported with regard to Bluetooth connections in iOS.
    iOS: Supported Bluetooth profiles

  • HT1695 How to connect my iPhone with the printers at school? Many thanks

    How to connect my iPhone with the printers at school? Many thanks

    They must be Airprint capable printers... if they are not, then there is no supported way of connecting to them.
    Airprint 101

  • How to connect Apple TV with an iPad ?

    How to connect Apple TV with iPad ?

    Welcome to the Apple Community.
    Assuming both devices are on the same network and that AirPlay is not turned off on the Apple TV, then simply tap on the screen when you are watching content you wish to stream to your Apple TV, then tap the airplay icon that appears in the control bar, choose the Apple TV from the menu that appears.
    When displaying the content you wish to mirror on the iPad 2 (or better), iPad Mini, iPhone 4S (or better), double tap the home button (quickly) and swipe the bottom row of apps to the right to reveal the playback controls, tap the AirPlay icon and select your Apple TV from the list of available devices.

  • I am a OS10.7.4 user. yesterday i bought a Lacie external hard disk but error message appear said " You cant open the applicant LaCie setup assistant because PowerPC applicants are no longer support". please help me how to connect my mac with Lacie??

    i am a OS10.7.4 user. yesterday i bought a Lacie external hard disk but error message appear said " You cant open the applicant LaCie setup assistant because PowerPC applicants are no longer support". please help me how to connect my mac with Lacie??

    You do not need the Setup Assistant; in fact, you do not need any software on an external hard drive. I have two LaCie's; I erased the drive as soon as I plugged it in. You will need to format it anyway because most hard drives come Windows formatted. So, if you only want to use it with the Mac, highlight it in Disk Utility and choose Mac OS Extended (Journaled) as the format and the GUID Partition scheme under Options. While doing that, it will erase the drive (and get rid of the LaCie software) - once finished, your drive is ready to use for Time Machine or any other backup plans you have for it.

  • To connect oracle database with ms access database

    i want to connect oracle database with ms access database
    i have follow the following steps
    1. create ms access database.
    2. create system dsn.
    3. make change in listener.ora.
    4. make change in hs folder.
    5.change the tnsname.ora.
    6. lsnrctl stop and lsnrct start.
    7. create database link in oracle sql*plus.
    8.select the table of ms access
    but i have return the foloowing error.
    ORA-12154: TNS:could not resolve the connect identifier specified
    using window 2000, oracle 10g

    Have a look on ths thread, may it helps ...
    Re: copy access data into oracle with form builder 9i

Maybe you are looking for

  • Error message from Internet Explorer v8.0.6

    My Muse test site is currently on Business Catalyst. The url is http://wfax-test.businesscatalyst.com - my client says that they get an error message from Internet Explorer version 8.0.6 "MuseJSAssert: error calling selector function: error: a securi

  • How to clear "recent" contacts listed automatically as you type email addresses in

    Hi everyone. When I go to type the address of an email I get as far as the first letter and a list of "recent" email addresses pops up, which is handy except for some reason the first one is a combination of two emails address, one I know and one I o

  • What went wrong here?

    Like I said in the picture, I changed my font size and font family for one of my <p> in one of my divs. Why did this change carry over to all my divs and <p>'s? What did I do wrong and what can I do to fix it? I am using Dreamweaver CS6 Thanks in adv

  • Moving project breaks merged clips...

    Hello, This is a complex and difficult problem to describe by writing, apologies if it's not clear. I've been working for several months on a large project that was shot double system: video imported as Pro Res (shot in HDV) and audio (recorded on DA

  • WBS  Wise - G / l Account Number  Informations

    Hi All,         If any BAPI is available for getting G / L Acc Information in WBS wise .Plz give me  that names. Thankx advances,,,