Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Database Connection

 
Archana Pillai
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 9063
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Archana Pillai
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 9063
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 />");
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic