dcsimg
How do i create and bind a datasource to the sqlserver jdbc driver
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Anonymous
Posted On:   Friday, May 24, 2002 01:58 AM

can ANYONE please assist i am attempting to create a datasource instance for the Microsoft jdbc driver and deploy it to jboss-tomcat directly attached is the info.jar file which cantains my complete source code, but excluding the jboss and MSSQLServerJdbc libraries my problems are two fold firstly see appendix 1 i'm not sure that the DataSource object is create correctly since after specifying all applicable properties, (all setXXX() methods) x.getConnection throws the following errors <------> java.lang.NoClassDefFoundError: com/merant/jdbcspy/SpyLogger at com.microsoft.jdbcx.base.BaseDataSource.getConnection(Unknown Source)    More>>

can ANYONE please assist

i am attempting to create a datasource instance for the
Microsoft jdbc driver and deploy it to jboss-tomcat directly

attached is the info.jar file which cantains my complete source code,
but excluding the jboss and MSSQLServerJdbc libraries

my problems are two fold
firstly see appendix 1
i'm not sure that the DataSource object is create correctly
since after specifying all applicable properties, (all setXXX() methods)
x.getConnection throws the following errors

<------>

			
java.lang.NoClassDefFoundError: com/merant/jdbcspy/SpyLogger
at com.microsoft.jdbcx.base.BaseDataSource.getConnection(Unknown Source)
at DeployHistoryDS.deploy(DeployHistoryDS.java:41)
at Deploy.deploy(Deploy.java:8)
at Intro.main(Intro.java:19)
Exception in thread "main"

<------>

what is spylogger

secondly see appendix 2
context.lookup(datasource) returns null
side-track
context.lookuplink(datasource) returns a reference. (not sure
what i can do with this)
context.lookup(datasource) throws a nullpointer exception if
called without lookup(ds) ???

nowhere do i specify a driver or connection string
i assume that this is the responsibility of the datasource
implementation provided by microsoft
if this is not the case how is the datasource implementation meant to be
used.

Thanx
Goolam


appendix 1
			
private static String host= "localhost";
private static String dbName= "History";
private static String description= "Maintains instrument info change
history";
private static String dsName= "History";
private static String subContext= "jdbc";
private static String user= "sa";
private static String pwd= "";
private static int port= 1433;
public static void deploy() throws NamingException {
// create a DataSource
SQLServerDataSource x= new SQLServerDataSource();
System.out.println(""History" DataSource instance created");
// properties
x.setServerName(host);
x.setDatabaseName(dbName);
x.setDescription(description);
x.setDataSourceName(dsName);
x.setUser(user);
x.setPassword(pwd);
x.setPortNumber(port);

System.out.println(""History" DataSource properties set");
/*//try connect
try{
Connection con =x.getConnection();
con.close();
} catch (SQLException sqle) {
Info.exceptionStuff(sqle,"Connection attempt");
} catch (Exception e) {
Info.exceptionStuff(e,"Connection attempt - other exception");
}
System.out.println(""History" DataSource connection
stuff");
*/
// deploy the datasource
Context context= MyContext.getContext();
try {
context.createSubcontext(subContext);
System.out.println("Created SubContext " + subContext);
}
catch (NameAlreadyBoundException nabe) {
System.out.println("SubContext " + subContext + " already
exists");
}
context.bind(name(), x);
System.out.println("" " + name() + " " bound to datasource");
context.close();
System.out.println("context closed");
}



appendix 2
			
private static String dsName="History";
private static String dsSubContext="jdbc";
public DataSource getDataSource() throws NamingException {
return getDataSource(dsSubContext+"/"+dsName);
}
public DataSource getDataSource(String source) throws NamingException {
System.out.println("attempting to find: "+source);
// Create Naming Context
Context context= MyContext.getContext();
// Get DataSource
Object obj;
// anomalous and i'm not sure why
// if i don't run lookup before lookupLink i get a
// NullPointerException unknown source
obj= context.lookup(source);
Info.info(obj,"lookup ds");
obj=context.lookupLink(source);
Info.info(obj,"lookuplink ds");
Reference ref=(Reference) obj;
Info.info(ref,"reference info");
/* post-condition
// the history database is now referable via dataSource
*/
return (DataSource) obj;
}
   <<Less
About | Sitemap | Contact