JSTL and SQL (with MS Access??)

  • Thread starter www.douglassdavis.com
  • Start date
W

www.douglassdavis.com

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.
 
B

Bryce

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
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.

For both, look at any JDBC tutorial you can find. You can use the
JDBC-ODBC bridge to get something working quickly.
 
H

hilz

www.douglassdavis.com said:
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.

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"/>
 
H

hilz

hilz said:
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"/>


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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

JSTL database access 0
Another Servlet/JSTL question 6
Beyond trivial JSTL 1
JSTL in JEE 2.5 2
Looking for SQL Book 2
Run SQL commands through Notepad++ 1
View page without JSTL 2
SQL Shell for MS Access 10

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,059
Latest member
cryptoseoagencies

Latest Threads

Top