'Invalid Class name driver JDBC SQLite
I have this error "Unable to get connection, DataSource invalid:
"java.sql.SQLException: No suitable driver found for /Users/testdb.db" when trying to select query from a database in JSP.
I was able to connect and query this database by adding the jar file sqlite-jdbc-3.15.1.jar when using Intellij, but hitting the error mentioned when run a dynamic web project in Eclipse, even I already add the jar file in the properties, as captured here:
Below is my code:
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib prefix="sql" uri = "http://java.sun.com/jsp/jstl/sql" %>
<%@ taglib prefix="c" uri = "http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<sql:setDataSource var = "db" driver="org.sqlite.JDBC"
url="jdbc:sqlite:/Users/test.db"/>
<sql:query var="rs" dataSource = "${db}">select * from contacts</sql:query>
<c:forEach items="${rs.rows}" var="contact">
<br>
<c:out value = "${contact.name}"></c:out>
</c:forEach>
</body>
</html>
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|

