• Post Reply Bookmark Topic Watch Topic
  • New Topic

J2EE Access/SQL Server 7  RSS feed

 
Nair Anoop
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I currently have a small J2EE app. which I made to learn this technology. It udes the default Cloudscape DB. I would now like to connect the same to MS Access or MS SQL using the JDBC-ODBC Bridge. I am using CMP. Could someone please outline the steps.
Would it make a difference if I used BMP.
Thanks.
Anoop
 
Nidhi Madan
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Asheet,
First of all go to your default.properties file in your config folder under your j2sdkee1.2.1 and put the statement in rem where
you are connecting with the cloudscape , i.e
#jdbc.datasources=jdbc/Cloudscape|jdbc:cloudscape:rmi:CloudscapeDB;create=true
and then instead of this write the following statement
jdbc.datasources=jdbc/sql|jdbc dbc:ejbdsn;create=true
now save this file an start your j2ee server again.
Note : ejbdsn can be any userdsn name in which you are creating the database in which u are making the tables u want to connect to the bean.
While deploying your example inthe codede refrence name give jdbc/databasename and the jndi name as jdbc/sql and the other jndi name give it what you are giving in your lookup call in the client.
if you are not able to get through it. mail me back again , i'll send you the small coded example as an attachment. send me your personal mail id as sending attachment is not possible here.
Hope it works for you. if u have any further problems mail me at nidhimadan14 yahoo.com
 
Nidhi Madan
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Asheet,
First of all go to your default.properties file in your config folder under your j2sdkee1.2.1 and put the statement in rem where
you are connecting with the cloudscape , i.e
#jdbc.datasources=jdbc/Cloudscape|jdbc:cloudscape:rmi:CloudscapeDB;create=true
and then instead of this write the following statement
jdbc.datasources=jdbc/sql|jdbcdbc:ejbdsn;create=true
now save this file an start your j2ee server again.
Note : ejbdsn can be any userdsn name in which you are creating the database in which u are making the tables u want to connect to the bean.
While deploying your example inthe codede refrence name give jdbc/databasename and the jndi name as jdbc/sql and the other jndi name give it what you are giving in your lookup call in the client.
if you are not able to get through it. mail me back again , i'll send you the small coded example as an attachment. send me your personal mail id as sending attachment is not possible here.
Hope it works for you. if u have any further problems mail me at nidhimadan14 yahoo.com
 
D Valentine
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Nidhi,
I am trying to connect to MSSQL server 7 using jdbcodbc bridge.
I have created a dsn named 'north' that connects to the Northwind db. In my j2sdk1.2.1/config/default.properties I done the following entries
#jdbc.drivers=COM.cloudscape.core.RmiJdbcDriver
jdbc.drivers=sun.jdbc.odbc.JdbcOdbcDriver
#jdbc.datasources=jdbc/Cloudscape|jdbc:cloudscape:rmi:CloudscapeDB;create=true
jdbc.datasources=jdbc/NorthDB|jdbcdbc:north;create=true
The following are the lines of code in AnimalBean.java connecting to db.
private String dbName = "java:comp/env/jdbc/AnimalDB";
String username = "north";
String password = "north";

public void ejbCreate() throws CreateException
{
try {
System.out.println(" In AnimalBean ejbCreate()");
makeConnection();
} catch (Exception ex) {
throw new CreateException(ex.getMessage());
}
}
private void makeConnection() throws NamingException, SQLException
{
try{
System.out.println(" In AnimalBean makeConnection()");
InitialContext ic = new InitialContext();
DataSource ds = (DataSource) ic.lookup(dbName);
con = ds.getConnection(username, password);
} catch (Exception e){
System.out.println("Error in makeConnection()" + e);
e.printStackTrace(System.out);
}
}
While deploying it in the Resource References:
I have entered 'jdbc/AnimalDB' in the first column under Coded Name. Type is 'javax.sql.DataSource', and Authentication is 'Container'. In the JNI Name Text filed I have entered 'jdbc/NorthDB' with no username and password.
Also I have also copied the rt.jar and tools.jar from jdk1.3 to j2sdk1.2.1\lib and set the J2EE_CLASSPATH=%classpath%.;%j2ee_home%\lib\j2ee.jar;%java_home%\lib\tools.jar;%java_home%\lib\rt.jar in the userconfig.bat file
I still get the error 'No Suitable Driver Error'. I will appreciate any kind of help.
Thankx and Regards,
Valentine
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!