javax.servlet.jsp.JspException:无法获得连接,数据源无效:"java.sql.SQLException:找不到合适的驱动程序" [英] javax.servlet.jsp.JspException: Unable to get connection, DataSource invalid: "java.sql.SQLException: No suitable driver found"
问题描述
我用jsp写了简单的代码,想从数据库中获取查询并在此页面中显示. 我的数据库已创建,并且中有一些示例数据,但是当我写时:
I write simple code in jsp and want to get a query from data base and show it in this page . my data base is created and have some sample data in , but when i write :
<sql:setDataSource var="co" driver="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost:3306/sys3"
user="root"
password="amir"
/>
<sql:query var="res" dataSource="co">
Select sec_id from section
</sql:query>
它在glassfish服务器上显示此错误:
it show this error on glassfish server :
javax.servlet.ServletException:javax.servlet.jsp.JspException:无法建立连接,数据源无效:"java.sql.SQLException:未找到合适的驱动程序"
javax.servlet.ServletException: javax.servlet.jsp.JspException: Unable to get connection, DataSource invalid: "java.sql.SQLException: No suitable driver found"
推荐答案
从此处,并将其添加到您的类路径中 另一件事改变
Download mysql-connector.jar
from here and add it to your classpath
One more thing change
<sql:query var="res" dataSource="co">
到
<sql:query var="res" dataSource="${co}">
这篇关于javax.servlet.jsp.JspException:无法获得连接,数据源无效:"java.sql.SQLException:找不到合适的驱动程序"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!