浏览 6924 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
|
|
---|---|
作者 | 正文 |
发表时间:2004-04-23
datasource设置: <?xml version='1.0' encoding='utf-8'?> <Context path="/test" docBase="D:/project/test/web" reloadable="true"> <Resource name="jdbc/D3Space" auth="Container" type="javax.sql.DataSource"/> <ResourceParams name="jdbc/D3Space"> <parameter> <name>factory</name> <value>org.apache.commons.dbcp.BasicDataSourceFactory</value> </parameter> <parameter> <name>driverClassName</name> <value>com.jnetdirect.jsql.JSQLDriver</value> </parameter> <parameter> <name>url</name> <value>jdbc:JSQLConnect://myserver/pubs</value> </parameter> <parameter> <name>username</name> <value>sa</value> </parameter> <parameter> <name>password</name> <value></value> </parameter> <parameter> <name>maxActive</name> <value>20</value> </parameter> <parameter> <name>maxIdle</name> <value>10</value> </parameter> <parameter> <name>maxWait</name> <value>-1</value> </parameter> </ResourceParams> </Context> hibernate.properties配置: hibernate.connection.datasource java:comp/env/jdbc/D3Space hibernate.connection.username sa hibernate.connection.password hibernate.dialect net.sf.hibernate.dialect.SQLServerDialect 定义类Publisher(对应表pubs/publishers) 执行 session.find(" from Publisher "); 出错: exception org.apache.jasper.JasperException org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:358) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248) javax.servlet.http.HttpServlet.service(HttpServlet.java:856) root cause java.lang.UnsupportedOperationException org.apache.commons.dbcp.PoolingDataSource.getConnection(PoolingDataSource.java:161) org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:532) net.sf.hibernate.connection.DatasourceConnectionProvider.getConnection(DatasourceConnectionProvider.java:56) net.sf.hibernate.impl.BatcherImpl.openConnection(BatcherImpl.java:278) net.sf.hibernate.impl.SessionImpl.connect(SessionImpl.java:3264) net.sf.hibernate.impl.SessionImpl.connection(SessionImpl.java:3244) net.sf.hibernate.impl.BatcherImpl.prepareQueryStatement(BatcherImpl.java:65) net.sf.hibernate.loader.Loader.prepareQueryStatement(Loader.java:704) net.sf.hibernate.loader.Loader.doQuery(Loader.java:185) net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:133) net.sf.hibernate.loader.Loader.doList(Loader.java:950) net.sf.hibernate.loader.Loader.list(Loader.java:941) net.sf.hibernate.hql.QueryTranslator.list(QueryTranslator.java:834) net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1512) net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1491) net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1483) com.test.PubliserManager.getPublishers(PubliserManager.java:61) org.apache.jsp.index_jsp._jspService(index_jsp.java:54) org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:133) javax.servlet.http.HttpServlet.service(HttpServlet.java:856) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:311) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248) javax.servlet.http.HttpServlet.service(HttpServlet.java:856) 声明:ITeye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
推荐链接
|
|
返回顶楼 | |
发表时间:2004-04-23
su 写道 怎么设了datasource无法执行sql?
但如果不用datasource,hibernate采用以下配置是可以查询出结果的:
datasource设置: <?xml version='1.0' encoding='utf-8'?> <Context path="/test" docBase="D:/project/test/web" reloadable="true"> <Resource name="jdbc/D3Space" auth="Container" type="javax.sql.DataSource"/> <ResourceParams name="jdbc/D3Space"> <parameter> <name>factory</name> <value>org.apache.commons.dbcp.BasicDataSourceFactory</value> </parameter> <parameter> <name>driverClassName</name> <value>com.jnetdirect.jsql.JSQLDriver</value> </parameter> <parameter> <name>url</name> <value>jdbc:JSQLConnect://myserver/pubs</value> </parameter> <parameter> <name>username</name> <value>sa</value> </parameter> <parameter> <name>password</name> <value></value> </parameter> <parameter> <name>maxActive</name> <value>20</value> </parameter> <parameter> <name>maxIdle</name> <value>10</value> </parameter> <parameter> <name>maxWait</name> <value>-1</value> </parameter> </ResourceParams> </Context> hibernate.properties配置: hibernate.connection.datasource java:comp/env/jdbc/D3Space hibernate.connection.username sa hibernate.connection.password hibernate.dialect net.sf.hibernate.dialect.SQLServerDialect 定义类Publisher(对应表pubs/publishers) 执行 session.find(" from Publisher "); 出错: exception org.apache.jasper.JasperException org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:358) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248) javax.servlet.http.HttpServlet.service(HttpServlet.java:856) root cause java.lang.UnsupportedOperationException org.apache.commons.dbcp.PoolingDataSource.getConnection(PoolingDataSource.java:161) org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:532) net.sf.hibernate.connection.DatasourceConnectionProvider.getConnection(DatasourceConnectionProvider.java:56) net.sf.hibernate.impl.BatcherImpl.openConnection(BatcherImpl.java:278) net.sf.hibernate.impl.SessionImpl.connect(SessionImpl.java:3264) net.sf.hibernate.impl.SessionImpl.connection(SessionImpl.java:3244) net.sf.hibernate.impl.BatcherImpl.prepareQueryStatement(BatcherImpl.java:65) net.sf.hibernate.loader.Loader.prepareQueryStatement(Loader.java:704) net.sf.hibernate.loader.Loader.doQuery(Loader.java:185) net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:133) net.sf.hibernate.loader.Loader.doList(Loader.java:950) net.sf.hibernate.loader.Loader.list(Loader.java:941) net.sf.hibernate.hql.QueryTranslator.list(QueryTranslator.java:834) net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1512) net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1491) net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1483) com.test.PubliserManager.getPublishers(PubliserManager.java:61) org.apache.jsp.index_jsp._jspService(index_jsp.java:54) org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:133) javax.servlet.http.HttpServlet.service(HttpServlet.java:856) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:311) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248) javax.servlet.http.HttpServlet.service(HttpServlet.java:856) hibernate.connection.driver_class com.jnetdirect.jsql.JSQLDriver hibernate.connection.url jdbc:JSQLConnect://myserver/pubs hibernate.connection.username sa hibernate.connection.password hibernate.dialect net.sf.hibernate.dialect.SQLServerDialect |
|
返回顶楼 | |
发表时间:2004-04-23
su 写道 怎么设了datasource无法执行sql?
但如果不用datasource,hibernate采用以下配置是可以查询出结果的:
datasource设置: <?xml version='1.0' encoding='utf-8'?> <Context path="/test" docBase="D:/project/test/web" reloadable="true"> <Resource name="jdbc/D3Space" auth="Container" type="javax.sql.DataSource"/> <ResourceParams name="jdbc/D3Space"> <parameter> <name>factory</name> <value>org.apache.commons.dbcp.BasicDataSourceFactory</value> </parameter> <parameter> <name>driverClassName</name> <value>com.jnetdirect.jsql.JSQLDriver</value> </parameter> <parameter> <name>url</name> <value>jdbc:JSQLConnect://myserver/pubs</value> </parameter> <parameter> <name>username</name> <value>sa</value> </parameter> <parameter> <name>password</name> <value></value> </parameter> <parameter> <name>maxActive</name> <value>20</value> </parameter> <parameter> <name>maxIdle</name> <value>10</value> </parameter> <parameter> <name>maxWait</name> <value>-1</value> </parameter> </ResourceParams> </Context> hibernate.properties配置: hibernate.connection.datasource java:comp/env/jdbc/D3Space hibernate.connection.username sa hibernate.connection.password hibernate.dialect net.sf.hibernate.dialect.SQLServerDialect 定义类Publisher(对应表pubs/publishers) 执行 session.find(" from Publisher "); 出错: exception org.apache.jasper.JasperException org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:358) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248) javax.servlet.http.HttpServlet.service(HttpServlet.java:856) root cause java.lang.UnsupportedOperationException org.apache.commons.dbcp.PoolingDataSource.getConnection(PoolingDataSource.java:161) org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:532) net.sf.hibernate.connection.DatasourceConnectionProvider.getConnection(DatasourceConnectionProvider.java:56) net.sf.hibernate.impl.BatcherImpl.openConnection(BatcherImpl.java:278) net.sf.hibernate.impl.SessionImpl.connect(SessionImpl.java:3264) net.sf.hibernate.impl.SessionImpl.connection(SessionImpl.java:3244) net.sf.hibernate.impl.BatcherImpl.prepareQueryStatement(BatcherImpl.java:65) net.sf.hibernate.loader.Loader.prepareQueryStatement(Loader.java:704) net.sf.hibernate.loader.Loader.doQuery(Loader.java:185) net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:133) net.sf.hibernate.loader.Loader.doList(Loader.java:950) net.sf.hibernate.loader.Loader.list(Loader.java:941) net.sf.hibernate.hql.QueryTranslator.list(QueryTranslator.java:834) net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1512) net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1491) net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1483) com.test.PubliserManager.getPublishers(PubliserManager.java:61) org.apache.jsp.index_jsp._jspService(index_jsp.java:54) org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:133) javax.servlet.http.HttpServlet.service(HttpServlet.java:856) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:311) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248) javax.servlet.http.HttpServlet.service(HttpServlet.java:856) hibernate.connection.driver_class com.jnetdirect.jsql.JSQLDriver hibernate.connection.url jdbc:JSQLConnect://myserver/pubs hibernate.connection.username sa hibernate.connection.password hibernate.dialect net.sf.hibernate.dialect.SQLServerDialect |
|
返回顶楼 | |
发表时间:2004-04-23
hibernate.properties中的
hibernate.dialect应该配置成net.sf.hibernate.dialect.SybaseDialect吧 |
|
返回顶楼 | |
发表时间:2004-04-23
如果sqlserver配置SybaseDialect分页时会出错,query语句会解释成limit(int1,int2)的形式。找到原因了,配置datasoure时,不能写成
<parameter> <name>url</name> <value>jdbc:JSQLConnect://myserver/pubs</value> </parameter> 而应写成: <parameter> <name>url</name> <value>jdbc:JSQLConnect://myserver</value> </parameter> <parameter> <name>DatabaseName</name> <value>pubs</value> </parameter> |
|
返回顶楼 | |
发表时间:2004-04-23
好象不稳定,又不行了,有没有别的解决方法????
|
|
返回顶楼 | |
发表时间:2004-04-23
<property name="hibernate.connection.url">jdbc:microsoft:sqlserver://yourserver;DatabaseName=yourdatabasename;SelectMethod=Cursor</property>
你试试,这是我看一个例子上写的,应该没错。 |
|
返回顶楼 | |
发表时间:2004-04-28
典型的pool设置的问题.
上面的URL我用MS 的驱动程序和Data Direct都没有问题. JTDS的就不用SelectMethod=Cursor这一选项. |
|
返回顶楼 | |