java - 通过 Netbeans 使用 mysql 时出现意外错误
问题描述
这是我的源代码,没有错误。我无法弄清楚出了什么问题。它给出了一个意想不到的错误,说“java.sql.driver”,我不知道该怎么做。
String v=jTextField1.getText();
DefaultTable DefaultTableModel = null;
DefaultTable model;
model = (DefaultTableModel);
jTable1.getModel();
try
{
Class.forName("java.sql.driver");
Connection c;
c=DriverManager.getConnection("jdbc:mysql://local host/hospital","root","hope");
Statement s=c.createStatement();
String q;
q = ("Select * from hospital where Patient_Name=v");
ResultSet r=s.executeQuery(q);
while(r.next())
{
int PNO=r.getInt("PNO");
String Patient_Name=r.getString("Patient_Name");
int Age=r.getInt("Age");
String Gender=r.getString("Gender");
String Department=r.getString("Department");
String Doctor=r.getString("Doctor");
model.addRow(new Object[]
{PNO,Patient_Name,Age,Gender,Department,Doctor});
r.close();
s.close();
e.close();
}
}catch (ClassNotFoundException e)
{
JOptionPane.showMessageDialog(null,e.getMessage());
} catch (SQLException e) {
JOptionPane.showMessageDialog(null,e.getMessage());
}
解决方案
推荐阅读
- java - 使用滚动视图?
- javascript - 如何用 0 初始化参数
- ios - iOS 中的依赖管理
- json - 如何使用 IMPORTJSON 函数将所有 json 数据返回到 Google 表格?
- android - 无法下载 auto-value.jar (com.google.auto.value:auto-value:1.5.2):没有可用于离线模式的缓存版本
- c# - 使用服务帐户上传 Google Drive 总是返回 403(存储配额)
- pandas - 了解 pandas 中日期时间的重采样
- drag-and-drop - 使用 Angular Material 选项卡时 onDragOver 非常慢
- cordova - ionic Cordova appAvailability 总是返回 false
- docker - 无法从另一个 docker 容器中的传输客户端连接到 ElasticSearch docker 容器