java.sql.SQLException: No suitable driver found for
myeclipse7.0的WebProject无法连接数据库求关键步骤?关键的代码如下,应该不是代码出问题了,高手指点一下intpageNum=5;intnextpage...
myeclipse7.0的WebProject无法连接数据库
求关键步骤?
关键的代码如下,应该不是代码出问题了,高手指点一下
int pageNum=5;
int nextpage=0,prepage=0;
int absRowNo=1;
int lastRowNo=0;
try{
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
}
catch(ClassNotFoundException e)
{
out.println(e.toString());
}
try{
Connection con=DriverManager.getConnection("");
Statement stmt=con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
ResultSet rs=stmt.executeQuery("SELECT*from student");
String absRowNoStr=request.getParameter("absRowNo");
if(absRowNoStr!=null)
{
absRowNo=Integer.parseInt(absRowNoStr);
}
rs.last();
lastRowNo=rs.getRow();
if(absRowNo>1)rs.absolute(absRowNo-1);
else rs.beforeFirst();
out.println
out.println
int curCount=0;
</body>
</html> 展开
求关键步骤?
关键的代码如下,应该不是代码出问题了,高手指点一下
int pageNum=5;
int nextpage=0,prepage=0;
int absRowNo=1;
int lastRowNo=0;
try{
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
}
catch(ClassNotFoundException e)
{
out.println(e.toString());
}
try{
Connection con=DriverManager.getConnection("");
Statement stmt=con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
ResultSet rs=stmt.executeQuery("SELECT*from student");
String absRowNoStr=request.getParameter("absRowNo");
if(absRowNoStr!=null)
{
absRowNo=Integer.parseInt(absRowNoStr);
}
rs.last();
lastRowNo=rs.getRow();
if(absRowNo>1)rs.absolute(absRowNo-1);
else rs.beforeFirst();
out.println
out.println
int curCount=0;
</body>
</html> 展开
2个回答
展开全部
连接的对象写错了,自己对照一下,看看那个地方写错了
package Dao;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
public class SqlServer {
String Driver="com.microsoft.sqlserver.jdbc.SQLServerDriver";
String username="sa";
String userpwd="sa";
String url="jdbc:sqlserver://localhost:1433;database=master";
public Connection getCon() throws SQLException, ClassNotFoundException{
Class.forName(Driver);
return DriverManager.getConnection(url,username,userpwd);
}
}
package Dao;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
public class SqlServer {
String Driver="com.microsoft.sqlserver.jdbc.SQLServerDriver";
String username="sa";
String userpwd="sa";
String url="jdbc:sqlserver://localhost:1433;database=master";
public Connection getCon() throws SQLException, ClassNotFoundException{
Class.forName(Driver);
return DriverManager.getConnection(url,username,userpwd);
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询