Solved

Java Applet Conneting to MSAccess Database

Posted on 1997-06-24
2
291 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

Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
groupSum6 challenge 6 86
numbers ascending pyramid 101 195
servlet  URL Rewriting 1 36
servlet example 11 40
After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
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 learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

773 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