0

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>

it show this error on glassfish server :

javax.servlet.ServletException: javax.servlet.jsp.JspException: Unable to get connection, DataSource invalid: "java.sql.SQLException: No suitable driver found"

BalusC
  • 992,635
  • 352
  • 3,478
  • 3,452
amir
  • 1,986
  • 3
  • 17
  • 44

3 Answers3

3

Download mysql-connector.jar from here and add it to your classpath One more thing change

<sql:query var="res" dataSource="co">

to

<sql:query var="res" dataSource="${co}">
SparkOn
  • 8,193
  • 3
  • 23
  • 28
1

Download MySQL Connector/J is the official JDBC driver for MySQL and place it under

WebContent
         |
         |__WEB-INF
                  |
                  |__lib
                       |
                       |__mysql-connector-java-5.0.x-bin.jar
Braj
  • 44,339
  • 5
  • 51
  • 69
0

You are missing the mysql jdbc connector from your class path. You can easily add it to the libraries if you are using any IDES or add it to the class path.