Hi Adrian, Which version of JRun are you using? If you're using JRun 4 then you should only pass the datasource name not "java:comp/env/jdbc."
Did you test the connection in the JMC? Was it successful? Try the code without the if statement before the try catch block. Ted Zimmerman -----Original Message----- From: adrian Albu [mailto:[EMAIL PROTECTED]] Sent: Wednesday, September 11, 2002 2:21 AM To: JRun-Talk Subject: data source and jrun 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 ______________________________________________________________________ This list and all House of Fusion resources hosted by CFHosting.com. The place for dependable ColdFusion Hosting. Archives: http://www.mail-archive.com/[email protected]/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists
