smike
asked on
Java Servlet & MS Access
hello
how can I access a MS Access database
from a servlet ?
please give me some examples
how can I access a MS Access database
from a servlet ?
please give me some examples
import javax.servlet.*;
import javax.servlet.http.*;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.sql.*;
public class TestDatabase extends HttpServlet
{
private Connection con;
private Statement stmt;
public void init(ServletConfig config)throws ServletException
{
super.init(config);
}
public void doGet(HttpServletRequest req,HttpServletResponse res)throws ServletException,IOExcepti on
{ ServletOutputStream out = res.getOutputStream();
out.println("enteredin the method");
String s = "CREATE TABLE IMAGE" + "(ADNO NUMBER(5) + ADNAME VARCHAR(10))";
try{
Class.forName("sun.jdbc.od bc.JdbcOdb cDriver");
}
catch(java.lang.ClassNotFo undExcepti on cnfe)
{
System.err.println("error class not found");
}
try{
con = DriverManager.getConnectio n("jdbc:od bc:Image", "ad","ad12 3");
out.println("Connected");
stmt = con.createStatement();
stmt.executeUpdate(s);
stmt.close();
con.close();
}
catch(SQLException sqe) //catch(SQLException ex)
{
System.err.println("sql exception");
}
}
}
import javax.servlet.http.*;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.sql.*;
public class TestDatabase extends HttpServlet
{
private Connection con;
private Statement stmt;
public void init(ServletConfig config)throws ServletException
{
super.init(config);
}
public void doGet(HttpServletRequest req,HttpServletResponse res)throws ServletException,IOExcepti
{ ServletOutputStream out = res.getOutputStream();
out.println("enteredin the method");
String s = "CREATE TABLE IMAGE" + "(ADNO NUMBER(5) + ADNAME VARCHAR(10))";
try{
Class.forName("sun.jdbc.od
}
catch(java.lang.ClassNotFo
{
System.err.println("error class not found");
}
try{
con = DriverManager.getConnectio
out.println("Connected");
stmt = con.createStatement();
stmt.executeUpdate(s);
stmt.close();
con.close();
}
catch(SQLException sqe) //catch(SQLException ex)
{
System.err.println("sql exception");
}
}
}
here my servlet usese access data base where i have stored image table which contains details of iamges
>>con = DriverManager.getConnectio n("jdbc:od bc:Image", "ad","ad12 3")
used fro connecting to data base :Image is DataSourceName which i have to configure through odbc configure option present in the control panel of windows
ad --usesrname for db
ad123 --password
>>con = DriverManager.getConnectio
used fro connecting to data base :Image is DataSourceName which i have to configure through odbc configure option present in the control panel of windows
ad --usesrname for db
ad123 --password
rjackman is correct
ASKER
rjackman,
your sevlet wrote "enteredin the method"
and thats all
do I need to install "JDBC-ODBC bridge" ?
smike: what is your server side? IIS?
ASKER
I have an Apache WWW Server and Apache JServ 1.1 on local machine, I have MS Access also
I'll copy all that stuff to a real server later
what is IIS ?
IIS - MS Inernet Information Server for NT
forget it :)
You can find all answers in my links
forget it :)
You can find all answers in my links
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
thanx for appreciation
RiuckyJackman
RiuckyJackman
Java Database Connectivity is a standard SQL database access interface, providing uniform access to a wide range of relational databases. It also provides a common base on which higher level tools and interfaces can be built. This comes with an "ODBC Bridge" (except on Mac 68K). The Bridge is a library which implements JDBC in terms of the ODBC standard C API.
http://java.sun.com/products/jdk/1.1/docs/guide/jdbc/index.html
http://java.sun.com/products/jdbc/index.html
http://java.sun.com/docs/books/jdbc/intro.html
http://java.sun.com/products/jdbc/faq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JDBC
http://java.sun.com/javareel/isv/Simba/products/jdbcfaq.html
Writing Advanced Applications Chapter 4: JDBC Technology
http://developer.java.sun.com/developer/onlineTraining/Programming/JDCBook/jdbc.html
This article covers the definition of database tables, use of Swing components, and gives a detailed code walkthrough with plenty of screen captures
http://developer.java.sun.com/developer/technicalArticles/Database/dukesbakery/
JDBC basics by Thornton Rose (example programs by April Rose)
http://www.gamelan.com/journal/techworkshop/060899_jdbc.html
JDBC and Database Programming in Java (good quick overview with images :)
http://www.purpletech.com/java/courses/jdbc/body.html
Silicaon Valley Java SIG JDBC Talk Page
http://www.hooked.net/~gturner/JDBCTalk.html
Java how-to DB section!
http://tactika.com/realhome/javaht/java-d1.html
http://codeguru.developer.com/java/Miscellaneous/Database/index.shtml
http://java.sun.com/products/jdk/1.3/ja/docs/ja/guide/jdbc/getstart/SimpleSelect.doc.html
articles from Oracle:
http://technet.oracle.com/tech/java/sqlj_jdbc/index.htm
articles from javaworld:
http://www.javaworld.com/javaworld/common/jw-ti-jdbc.html
JDBC 2.0 New Features
http://java.sun.com/products/jdk/1.3/docs/guide/jdbc/getstart/appendixA.html#1006294
http://java.sun.com/docs/books/tutorial/jdbc/jdbc2dot0/index.html
MS bridge
http://www.microsoft.com/Java/sdk/relnotes/JDBCrel.htm
http://msdn.microsoft.com/downloads/samples/Internet/author/datasrc/jdbcapplet/default.asp
Drivers:
http://java.sun.com/products/jdbc/drivers.html
http://developer.java.sun.com/developer/onlineTraining/Programming/JDCBook/jdbc.html#driver
http://tactika.com/realhome/javaht/java-d1.html#d8
ODBC Drivers, Servers, and Vendors
http://ourworld.compuserve.com/homepages/Ken_North/odbcvend.htm
JDBC Drivers, Servers, and Vendors
http://ourworld.compuserve.com/homepages/Ken_North/jdbcvend.htm
http://www.softsyn.com/Vendors.htm
http://www.idssoftware.com/jdriver.htm
Base source code to build your own JDBC driver http://dyade.inrialpes.fr/membres/gibello/JDBC/jdbcImpl.html
Books online
http://www.itknowledge.com/reference/standard/1576100561/book-index.html
Java Database Programming with JDBC
http://www.itknowledge.com/reference/standard/1576100561/book-index.html
Java 1.2 Unleashed : Connecting to Databases with the java.sql Package
http://www.itknowledge.com/reference/standard/1575213893/ch44/ch44.htm
and some useful DB stuff:
InstantDB
http://208.234.21.207/
WebLogic JDBC (30 day trial)
http://www.beasys.com/download/weblogic.html
http://www.thoughtinc.com/cocofree/doc/index.html
http://www.agave.com/html/products/jdbc_dwnld.htm
--
--
DbVisualizer
http://www.pureit.se/products/dbvis/
DbVisualizer is a powerful Java tool for navigating one or many JDBC enabled databases simultaneously. It graphically visualizes relations between tables (for databases supporting referential integrity), it displays information about columns, indexes, primary keys, stored procedures and more. Any SQL statement can be executed using the SQL Commander and they can be organized and stored for subsequent use.
----
http://java.sun.com/products/jdbc/faq.html#5
How can I use the JDBC API to access a desktop database like Microsoft Access over the network?
Most desktop databases currently require a JDBC solution that uses ODBC underneath. This is because the vendors of these database products haven't implemented all-Java JDBC drivers.
The best approach is to use a commercial JDBC driver that supports ODBC and the database you want to use. See the JDBC drivers page for a list of available JDBC drivers.
The JDBC-ODBC bridge from Sun's Java Software does not provide network access to desktop databases by itself. The JDBC-ODBC bridge loads ODBC as a local DLL, and typical ODBC drivers for desktop databases like Access aren't networked. The JDBC-ODBC bridge can be used together with the RMI-JDBC bridge , however, to access a desktop database like Access over the net. This RMI-JDBC-ODBC solution is free. http://dyade.inrialpes.fr/mediation/download/