File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Other Java Products and Servers and the fly likes Database Connection Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Other Java Products and Servers
Bookmark "Database Connection" Watch "Database Connection" New topic
Author

Database Connection

Archana Pillai
Greenhorn

Joined: Oct 08, 2002
Posts: 11
I am trying to connect Access Database within a servlet. How do I go about doing this in Orion.
Note : I am new to both Servlets and Orion server
Marilyn de Queiroz
Sheriff

Joined: Jul 22, 2000
Posts: 9046
    
  10
You don't connect to Access database (or any other database) in Orion. You use JDBC in your servlet. Then you can put your servlet on whatever webserver you want, Orion, Tomcat, JRun, or another server.


JavaBeginnersFaq
"Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
Archana Pillai
Greenhorn

Joined: Oct 08, 2002
Posts: 11
Thanks for ur reply.
Actually that is exactly what I meant. I am trying to use JDBC in my servlet.I am giving the code

My orion data-sources.xml
<data-source
class="com.evermind.sql.DriverManagerDataSource"
name="Test data-source"
location="jdbc/TestCoreDS"
xa-location="jdbc/xa/TestXADS"
ejb-location="jdbc/Test"
connection-driver="sun.jdbc.odbc.JdbcOdbcDriver"
username=""
password=""
url="jdbc dbc:test.mdb"
schema="database-schemas/ms-access.xml"
inactivity-timeout="30">
</data-source>
But it gives me data not found error...I am going crazy. Can u help. The docs don't help. I am thinking of uninstalling orion.'coz Tomcat seems to have better docs.
What is ur suggestion.
Archana
[ November 12, 2002: Message edited by: Marilyn de Queiroz ]
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Why don't u try Loading the Driver into Memory using the traditional Class.forName() method . and then use the getConnection() of DriverManager to get u'r connection objects insted of using a DataSource.
You could also use one of the Connection Pooling mechanism's to dispense u'r connection Objects instead of Creating & taking down connection's in The doGet() method .
Another Benifit is that if tommorow u can still configure u'r DataSource to return connections , u could Just change the implementation in u'r Connection Pool Class..
Hope this helps .
Marilyn de Queiroz
Sheriff

Joined: Jul 22, 2000
Posts: 9046
    
  10
I think I would create the connection in the Servlet rather than in the xml descriptor. You might find this page helpful.
Mike Curwen
Ranch Hand

Joined: Feb 20, 2001
Posts: 3695

Or, if you want to use orion's DataSource facility, try this site for general Orion docs, and your issue in particular:

http://kb.atlassian.com/content/orion/docs/configuration/data-sources.xml.html

I've never used Orion myself, so don't know if there docs are worse or better than this, but atlassian has some fair amount of experience with Orion.

Have you tried:
DataSource ds = (DataSource) ctx.lookup("jdbc/TestCoreDS");

You are trying to pull the ejb-location DS, and perhaps you've chosen a driver class that doesn't "go" with ejb-location.

Also, what is the EXACT error message (Stack trace) that you are getting, and where is it appearing?
Archana Pillai
Greenhorn

Joined: Oct 08, 2002
Posts: 11
Hi,
Thanks for all ur responses.
I tried using
DataSource ds = (DataSource) ctx.lookup("jdbc/TestCoreDS");
And I get the following error...
Entering hijdbc/Test connection I am here before Stmt java.sql.SQLException: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
in my browser when I run the servlet.
As far as connection pooling goes. I am yet to read up on them.
Thanks,
Archana
Mike Curwen
Ranch Hand

Joined: Feb 20, 2001
Posts: 3695

That sounds a lot like your DataSource is configured correctly in Orion, but you haven't entered a proper DSN in Windows.

Because you're using the jdbc/odbc bridge, you need to make sure your Access database has a system DSN. (your connection URL has "jdbcdbc:test.mdb", and 'test.mdb' is the DSN that the driver will look for.

I've never used the jdbc/odbc bridge before, so I can't tell if that's a properly formed URL, but it looks like you've just specified a file name (without even a path). This probably won't work.
[ November 13, 2002: Message edited by: Mike Curwen ]
Mike Curwen
Ranch Hand

Joined: Feb 20, 2001
Posts: 3695

DSN is the "Data Source name" that is not being found in the following error message: [Microsoft][ODBC Driver Manager] Data source name not found.

This is NOT the jdbc/Test datasource. That IS being found. It's the Microsoft DSN that isn't found.

and 2nd: as a tip, when you System.out.println() to a servlet, it all appears on one line because browsers don't listen to '\n' characters. Put something like System.out.print(conn + "<br />");
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Database Connection