Hello,
I have a question, very important to me because I have a dead-line :)
So I am using JRun with Microsoft SQLServer 2000 with Microsoft SQLServer 2000
Driver for JDBC. First of all when I use jdbc1, without datasource it works fine but
we
have to use jdbc 2 so I am making an data source in JRun, with the console,
with an name for it. I want to ask you this: I know a data source should be bind to
a contex before used but I dono if this is done by JRun or should I do it myself?
By the boss he send me this:
//data source name is setup in web.xml
dataSourceName = getInitParameter(DATA_SOURCE_NAME);
if (dataSourceName == null) {
System.err.println("dataSourceName param was null in web.xml
!");
//default data source name
throw new ServletException("dataSourceName param was null in
web.xml !") ;
}
try {
javax.naming.InitialContext ctx = new
javax.naming.InitialContext();
dataSource =
(javax.sql.DataSource)ctx.lookup("java:comp/env/jdbc/" + dataSourceName);
}
catch (NamingException ne) {
ne.printStackTrace();
throw new ServletException("The DataSource object creation
failed !") ;
}
and after that you use it like this:
dbConnection = dataSource.getConnection();
queryStatement = dbConnection.prepareStatement(sql);
rs = queryStatement.executeQuery();
So I put the name ot the ds form JRun in web.xml, I get it and try to get the ds like
shown above and I get this error:
java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]Object has been
closed.
Is this because of the ds not found or what?
And where from is the context:java:comp/env/jdbc/?
Thanks,
Adrian
---------------------------------
Yahoo! - We Remember
9-11: A tribute to the more than 3,000 lives lost
______________________________________________________________________
Your ad could be here. Monies from ads go to support these lists and provide more
resources for the community. http://www.fusionauthority.com/ads.cfm
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists