struts连接数据库报错!  

04-04-03 mikecaolei
我检查过web.xml文档中的数据库部分数据都读取正确,就是在调用GenericDataSource.open()方法连接数据库的时候出错,请帮忙看看,有什么办法可以解决这个问题,以及为什么会出现这个问题?

具体报错内容是:
javax.servlet.UnavailableException: Initializing application data source
conPool
at org.apache.struts.action.ActionServlet.initModuleDataSources(ActionServlet.java:1091)
at org.apache.struts.action.ActionServlet.init(ActionServlet.java:472)
at javax.servlet.GenericServlet.init(GenericServlet.java:82)
at com.caucho.server.http.Application.createServlet(Application.java:3103)
at com.caucho.server.http.Application.loadServlet(Application.java:3054)
at com.caucho.server.http.Application.initServlets(Application.java:1914)
at com.caucho.server.http.Application.init(Application.java:1827)
at com.caucho.server.http.VirtualHost.startApplication(VirtualHost.java:1192)
at com.caucho.server.http.VirtualHost.cron(VirtualHost.java:1335)
at com.caucho.server.http.ServletServer.cron(ServletServer.java:1883)
at com.caucho.server.http.ServletServer.handleCron(ServletServer.java:1721)
at com.caucho.util.Cron$CronThread.evaluateCron(Cron.java:199)
at com.caucho.util.Cron$CronThread.run(Cron.java:163)
<p>

mikecaolei
2004-04-03 23:39

 web.xml部分是这样的:
<servlet>
   <servlet-name>database</servlet-name>
   <servlet-class>diagnosis.servlets.DatabaseServlet</servlet-class>
   <init-param>
     <param-name>debug</param-name>
     <param-value>2</param-value>
   </init-param>
   <init-param>
     <param-name>driverClass</param-name>
     <param-value>sun.jdbc.odbc.JdbcOdbcDriver</param-value>
   </init-param>
   <init-param>
     <param-name>jdbcURL</param-name>
     <param-value>jdbc:odbc:diagnosis</param-value>
   </init-param>
   <init-param>
     <param-name>minCount</param-name>
     <param-value>1</param-value>
   </init-param>
   <init-param>
     <param-name>maxCount</param-name>
     <param-value>2</param-value>
   </init-param>
   <init-param>
     <param-name>user</param-name>
     <param-value>sa</param-value>
   </init-param>
   <init-param>
     <param-name>password</param-name>
     <param-value>sa</param-value>
   </init-param>
   <load-on-startup>2</load-on-startup>
 

 java部分是这样的:
String value = getServletConfig().getInitParameter("debug");
ds = new GenericDataSource();
ds.setDriverClass(getInitParameter("driverClass"));
ds.setUrl(getInitParameter("jdbcURL"));
ds.setMinCount(Integer.parseInt(getInitParameter("minCount")));
ds.setMaxCount(Integer.parseInt(getInitParameter("maxCount")));
ds.setUser(getInitParameter("user"));
ds.setPassword(getInitParameter("password"));
ds.setAutoCommit(true);
try {
ds.open();
ConnectionPool.init(ds);
} catch(SQLException e) {
e.printStackTrace();
}}
 
 

 
 

猜你喜欢