choyri / chaolib Goto Github PK
View Code? Open in Web Editor NEW图书馆管理系统。课程设计。
License: MIT License
图书馆管理系统。课程设计。
License: MIT License
我最近在做java web的项目,觉得您的项目写的很好,想借鉴学习一下,但是我的数据库jdbc驱动一直报错。我首先添加了我的jar包在类目录下,然后添加进build path里,但是我用的是您写的第二种连接方法,它一直在报错,您知道是什么原因吗?是我的驱动有问题吗?
我把DBConection.java改成了如下形式:
package com.choyri.util;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.sql.DataSource;
/**
* 数据库连接
*/
public class DBConnection {
private Connection conn = null;
/*
// 数据库连接池
public DBConnection() {
DataSource ds = null;
try {
ds = (DataSource) (new InitialContext()).lookup("java:comp/env/jdbc/mariadb");
} catch (NamingException e) {
e.printStackTrace();
}
try {
conn = ds.getConnection();
} catch (SQLException e) {
e.printStackTrace();
}
}*/
// 传统连接
public DBConnection() {
try {
conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/chaolib", "root", "root");
} catch (SQLException e) {
e.printStackTrace();
}
}
public Connection getConnection() {
return conn;
}
public void close() {
if (conn != null) {
try {
conn.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
}
}
它报的错是
java.sql.SQLException: No suitable driver found for jdbc:mysql://localhost:3306/chaolib
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.