Solved

Java Applet Conneting to MSAccess Database

Posted on 1997-06-24
2
292 Views
Last Modified: 2013-11-23
How could I connect a java applet to an Access Database File?
I need to write an applet to search a list of phone numbers,email addresses and server them to the person who accessed the web page. I am a relative beginer so the more complete the answers the better.
0
Comment
Question by:Sean Milne
2 Comments
 
LVL 6

Accepted Solution

by:
jpk041897 earned 150 total points
ID: 1222097
The answer to your question is really to extensive to answer completley in this forum so I'll just give you some pointers you can pursue, and then you can clarify your doubts via additional comments to this question.

For Java to access a Data Base of any kind, you need to use JDBC (included in the JDK1.1 release and downloadable from sun for 1.02).

For an Access database, you would need the JDBC-ODBC bridge (which is part of JDBC) and an ODBC driver for MS Access.

There are several good resources you can read to learn how to use JDBC. Amongst them, online, take a look at:

http://www.mcp.com/que/et/se_java2e/43javafi.htm

http://www.mcp.com/que/et/se_java2e/44javafi.htm

http://www.mcp.com/que/et/se_java2e/45javafi.htm

http://splash.javasoft.com/jdbc/#The JDBC Release 1.2

and if you are looking for Java DB development tools you might want to look at:

http://www.xdb.com/home.htm

The info contained in these pages should be enough to get you started. And leave you in a position in which you can ask more specific questions that could lead to a conclution.

Feel free to post as many clarification comments as you wish, and  if at any time during the process you believe my comments are not addressing your needs, grade me with an F to handoff your question to another "expert".
0
 

Expert Comment

by:suhai
ID: 1222098
Java Applet can connect to MSAccess Database using JDBC-ODBC. If you using JDK1.1.1 just include in classpath(autoexec).
You have to download JDBC package if using JDK1.02. To communicate your applet & your database on browser, i suggest you Symantec dbAnywhere Server(Netscape only). Please refer to  
http://www.symantec.com 
check the documentation for dbAnywhere (configuration C for MSAccss) & download Trial dbAnywhere Server for testing.

SET PATH=C:\WINDOWS;C:\WINDOWS\COMMAND;C:\Jdk1.1.1\Bin;c:\jdk1.1.1\jdbc\classes\sun\jdbc\odbc;"%PATH%"
SET PATH=C:\WINDOWS;C:\WINDOWS\COMMAND;C:\jdk1.1.1\lib;C:\jdk1.1.1\jdbc;C:\jdk1.1.1\jdbc\classes;"%PATH%"
SET PATH=C:\dbANYWHERE Server\redist\dbaw.zip;C:\dbANYWHERE Server\redist\sql.zip;"%PATH%"

SET CLASSPATH=.;C:\JDK1.1.1\LIB\CLASSES.ZIP;C:\dbANYWHERE Server\redist\dbaw.zip;c:\dbANYWHERE Server\redist\sql.zip

Java applet/application:
public void setup()
{
 Connection myConnection;
 Statement myStmt;
 String url = "jdbc:odbc:yourdatabase"; //yourdatabase is example
 try                                  //use your own                                       //  source database
 {      
   Class.forName ("sun.jdbc.odbc.JdbcOdbcDriver");
   myConnection = DriverManager.getConnection(url, " ", " ");
   myStmt = myConnection.createStatement();
 }
 catch (java.sql.SQLException e){
      System.out.println("SQL Pass Exception");
 }
 catch (java.lang.Exception e2){                          System.out.println("Java Lang Pass Exception");      
 }
}
for dbAnywhere connection:
driver =(Driver)Class.forName("symantec.itools.db.jdbc.Driver").newInstance();
DriverManager.registerDriver(driver);
String url = "jdbc:dbaw://192.168.0.9:8889/MS_Access/newdatabase/newdatabase";

String user = " ";
String password = " ";
con = DriverManager.getConnection(url,user,password);
stmt = con.createStatement();
   

You have to setup your database in Control Panel 32bitODBC and add MSAccess Driver .mdb(then select your database)
You can use SQL language to insert,delete,update from database
ex: Resutselt myresult;
    try{
      string sql = "select * from Emloyee where ....";
      myresult = myStmt.executeQuery(sql);  
      while(myresult.next())
      {
           myResult.getString("staffid");
      }
     catch (java.sql.SQLException e){
      System.out.println("SQL Pass Exception");
      }
     catch (java.lang.Exception e2){                                  System.out.println("Java Lang Pass Exception");      
     }

I suggest you to use Visual Cafe Pro to build & compile your applet.

I hope this help.

Pablo.


0

Featured Post

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
egit plugin on eclipse 8 82
hibernate insert example 13 34
servlet web applications   metadata-complete="true" or false 3 131
JavaFX TableView not displaying correctly 3 62
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question