Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

EJBs using Access database  RSS feed

 
Ben Field
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
Can someone please show me how to link up MS Access into J2EE so they can be used by entity beans. I'm sure its something to do with setting up ODBC data source in control panel....
I am using J2EE 1.3.1
Thanks.
 
Raj Chila
Ranch Hand
Posts: 128
Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ben,
By Default the Sun one Application server supports the following Databases,
Datadirect Technologies,Oracle´┐Ż 9.0.1,PointBase.
More over if you want to connect to a Database then you need a JDBC Driver for that database (preferably type 4. all the drivers for the above databases are type 4 only).
So in your case, I think you will have to depend on a JDBC : ODBC Bridge driver for accessing MS Access Database.
You will have to create a System DSN preferably as it will be visible to all users and other services (applies for windows Environment).
open controlPanel->Administrative tools -> Data Sources (ODBC) and create
a new DSN for MsAccess
select the System DSN Tab and click on Add
select the Driver (Microsoft Access Driver (*.mdb)).
enter a Data source Name
and then select / Create the database
Then you will have to configure your J2EE server to use the correct driver for the Database.
I hope this helps.
[ March 28, 2004: Message edited by: RajaniKanth Bhargava ]
 
Ben Field
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks - I have set up the data source, but it is the
"Then you will have to configure your J2EE server to use the correct driver for the Database"
part that I do not understand how to do....
 
Raj Chila
Ranch Hand
Posts: 128
Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi Ben,
follow this link and it is pretty easy to set up a database connectivity in the Sun one application server.
Setting up databases in sun one
I have not worked on this before so I dont really know if I can add a new database configuration. I think it should be possible.
ofcourse you will not need to do all this if you are creating EJBs with Bean Managed Persistence, then you will probably try to create a Utility class that will create the connections and provides a bridge to the Database Driver.
The above "Configuring" is needed if you want to depend on the container for the CMP or want to provide a JNDI support to the Database connection and pooling. so that your EJBs request the context to return the Datasource instead of you assigning it to some utility class....but at the end of the day, I think creating a uitlity class like this is not a good practice.
All said and done I still think it will be possible to "configure" the server.
Regards
Rajanikanth
[ March 29, 2004: Message edited by: RajaniKanth Bhargava ]
[ March 29, 2004: Message edited by: RajaniKanth Bhargava ]
 
Ben Field
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your help Rajanikanth.
The document keeps talking about adding drivers into the console. what console? I am using 1.3 which doesn't appear to have an (admin?) console.
I read in the ConfigGuide to add jdbc drivers by typing:
j2eeadmin -addjdbcDriver sun.jdbc.odbc.JdbcOdbcDriver
and then:
j2eeadmin -addJdbcDatasource jdbc/Employee jdbc dbc:Employee_DB
I've set up my System DSN to be Employee_DB in control panel
And I try and access the data source using:
DataSource ds = (DataSource) ic.lookup("java:comp/env/jdbc/Employee");
but all I get is NameNotFoundException....
any idea what I am doing wrong?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!