Solved

Java Applet Conneting to MSAccess Database

Posted on 1997-06-24
2
289 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
Comment Utility
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
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
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…

743 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now