For the purposes of doing a demonstration, and since Access is the DB
that we have in the class I am teaching in, I am trying to connect JSP
with MS Access. It is very difficult to find any examples that do
this. As a matter of fact, I am having trouble finding examples of
the JSTL using SQL at all.
Can any one point me to an example? Or give me some hints on how I
should do this? If you you know of a simple example that doesn't use MS
Access, perhaps you can point me to that and I could modify it for
access, I would appreciate if you could point me to that one, and
possibly I could modify it for Access.
Oh yea, and I would like to make a servlet that accesses a database
too. If you have tips, or code on how to do this, please, let me know.
Thanks.
--
http://www.douglassdavis.com
Bryce - 07 Nov 2005 18:15 GMT
>For the purposes of doing a demonstration, and since Access is the DB
>that we have in the class I am teaching in, I am trying to connect JSP
>with MS Access. It is very difficult to find any examples that do
>this. As a matter of fact, I am having trouble finding examples of
>the JSTL using SQL at all.
That's because most people don't use SQL at the JSP level.
>Can any one point me to an example? Or give me some hints on how I
>should do this? If you you know of a simple example that doesn't use MS
[quoted text clipped - 4 lines]
>Oh yea, and I would like to make a servlet that accesses a database
>too. If you have tips, or code on how to do this, please, let me know.
For both, look at any JDBC tutorial you can find. You can use the
JDBC-ODBC bridge to get something working quickly.
--
now with more cowbell
hilz - 07 Nov 2005 19:02 GMT
> For the purposes of doing a demonstration, and since Access is the DB
> that we have in the class I am teaching in, I am trying to connect JSP
[quoted text clipped - 15 lines]
> --
> http://www.douglassdavis.com
I just did that with tomcat and HSQLDB
After hunting it down in the tomcat documentation and the J2ee tutorial
at the following links, and with some modifications, i was able to get
the connection to work:
http://tomcat.apache.org/tomcat-5.5-doc/index.html
http://java.sun.com/j2ee/1.4/docs/tutorial/doc/index.html
So here is what got me up and running:
in the <Context> element of the context.xml
<resource-ref>
<description>some description</description>
<res-ref-name>petra_db</res-ref-name>
<res-ref-type>javax.sql.DataSource</res-ref-type>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
<ResourceLink global="petra_db" name="petra_db"
type="javax.sql.DataSource"/>
and in the <GlobalNamingResources> element of the server.xml
<Resource
name="petra_db"
type="javax.sql.DataSource"
driverClassName="org.hsqldb.jdbcDriver"
password=""
maxIdle="2"
maxWait="5000"
username="sa"
url="jdbc:hsqldb:hsql://petra"
maxActive="4"/>
hilz - 07 Nov 2005 19:09 GMT
>> For the purposes of doing a demonstration, and since Access is the DB
>> that we have in the class I am teaching in, I am trying to connect JSP
[quoted text clipped - 47 lines]
> url="jdbc:hsqldb:hsql://petra"
> maxActive="4"/>
and here is how you do the connection:
Context initCtx = new InitialContext();
Context envCtx = (Context) initCtx.lookup("java:comp/env");
// Look up our data source
DataSource ds = (DataSource)
envCtx.lookup("petra_db");
// Allocate and use a connection from the pool
connection = ds.getConnection();
And please do not multipost. see here:
http://mindprod.com/jgloss/multiposting.html
...setting followup to c.l.j.programmer.
HTH