java远程链接access数据库,报 No suitable driver
Class.forName("org.objectweb.rmijdbc.Driver").newInstance();Stringurl="jdbc:rmi://192...
Class.forName("org.objectweb.rmijdbc.Driver").newInstance();
String url = "jdbc:rmi://192.168.211.128/jdbc:odbc:JDBC_ODBC";
Connection con = DriverManager.getConnection(url);
Statement st = con.createStatement();
String sql = "select * from ajun";
ResultSet rs = st.executeQuery(sql);
while(rs.next())
{
%>
<tr>
<td><%=rs.getInt(1)%></td>
<td><%=rs.getString(2) %></td>
<td><%=rs.getString(3) %></td>
</tr>
<%
}
rs.close();
st.close();
con.close();
%>
一直报org.apache.jasper.JasperException: javax.servlet.ServletException: java.sql.SQLException: No suitable driver
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:541)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:417)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
root cause javax.servlet.ServletException: java.sql.SQLException: No suitable driver
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:850)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:779)
org.apache.jsp.index_jsp._jspService(index_jsp.java:131)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWr....................................
求各位大神帮忙指点!! 展开
String url = "jdbc:rmi://192.168.211.128/jdbc:odbc:JDBC_ODBC";
Connection con = DriverManager.getConnection(url);
Statement st = con.createStatement();
String sql = "select * from ajun";
ResultSet rs = st.executeQuery(sql);
while(rs.next())
{
%>
<tr>
<td><%=rs.getInt(1)%></td>
<td><%=rs.getString(2) %></td>
<td><%=rs.getString(3) %></td>
</tr>
<%
}
rs.close();
st.close();
con.close();
%>
一直报org.apache.jasper.JasperException: javax.servlet.ServletException: java.sql.SQLException: No suitable driver
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:541)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:417)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
root cause javax.servlet.ServletException: java.sql.SQLException: No suitable driver
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:850)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:779)
org.apache.jsp.index_jsp._jspService(index_jsp.java:131)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWr....................................
求各位大神帮忙指点!! 展开
2个回答
展开全部
检查这4个问题:
连接URL格式是否有问题
驱动字符串是否正确
驱动是否在classpath中
JDBC_ODBC这个数据源是否在服务器上创建?
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
数据库驱动jar包build path了吗
追问
build path 了,用此方法本机的数据库是可以访问的!
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询