Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / First Aid / November 2005

Tip: Looking for answers? Try searching our database.

JSTL and SQL (with MS Access??)

Thread view: 
www.douglassdavis.com - 07 Nov 2005 16:31 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.

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


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.