日期:2014-05-18  浏览次数:20747 次

java6中的derby数据库的连接问题
jsp页面打开后的问题:java.sql.SQLException: No suitable driver found for jdbc:derby://localhost:1527/pengrenjieDB 

我的机器配置:jdk1.6.0_03,NetBeans 6.0
 程序代码如下:
<%@ page contentType="text/html; charset=GB2312" language="java" import="java.sql.*,java.util.*;" errorPage=""%>
<html>
<head>
<title>学籍管理系统</title>
</head>
<%! String url,sql; %>
<%! Connection conn;//定义数据库连接对象 %>
<%! ResultSet rs;//定义结果集对象 %>
<%! Statement stmt;//定义SQL语句对象 %>
<%! int i;%>
<body bgcolor="#ffffff">
<div align="center"><font color="#000000" size="5">学籍管理系统 </font> </div>
<table width="75%" border="1" cellspacing="1" cellpadding="1" align="center">
  <tr>
  <td width=16% align=center>学号</td>

<td width=12% align=center>更改</td>
<td width=12% align=center>删除</td>
  </tr>
  <%
try{
   
  String url = "jdbc:derby://localhost:1527/pengrenjieDB";
  String username = "admin";
  String password = "12345678";
Connection conn = DriverManager.getConnection(url,username,password);//建立与数据库的连接
stmt = conn.createStatement();
sql = "select * from AA"; 
rs = stmt.executeQuery(sql);//查询数据库
while (rs.next()) {
  %>
  <tr>
  <td width=16% align=center><%=rs.getObject(1)%></td>

<td width=12% align=center><a href="change.jsp?xuehao=<%=rs.getObject(1)%>">修改</a></td>
<td width=12% align=center><a href="del.jsp?xuehao=<%=rs.getObject(1)%>">删除</a></td>
  </tr>
  <%
}
rs.close();
stmt.close();
conn.close();
}catch(Exception e){
out.println(e);
}
  %>
</table>
<div align="center"><a href="insert.jsp">添加新记录 </a> </div>
</body>
</html>


------解决方案--------------------
Driver d = (Driver) Class.forName("org.apache.derby.jdbc.EmbeddedDriver").newInstance();
可以用这个驱动.