郁闷了一天了?为何会这样的提示?
从这里开始是正确的
1000
1221
some wrong have happen
******
SQLException catch******** SQLState:IM002 Message:[Microsoft][ODBC 驱动程序管理器]
未发现数据源名称并且未指定默认驱动程序 Vendor:0
如果你能看到这里,就那行了
程序代码:
<%@ page import= "java.sql.* " contentType= "text/html;charset=gb2312 " %>
<HTML>
<BODY>
<%
out.println( "从这里开始是正确的 <br/> ");
%>
<%
Connection con=null;
Statement stmt=null;
ResultSet rs=null;
String sql= "select * from user_table ";
try{ out.println( "1000 <br/> ");
Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver ");
}
catch(
ClassNotFoundException e){
System.err.print(e.getMessage());
}
try{
out.println( "1221 <br/> ");
con=DriverManager.getConnection( "jdbc:odbc:bank_data ", "sa ", "123456 ");
out.println( "2222 <br/> ");
stmt=con.createStatement();
out.println( "2112 <br/> ");
rs=stmt.executeQuery(sql);
while(rs.next()){out.println(rs.getString( "1 "));}
con.close();
}
catch(SQLException ex)
{
out.println( "some wrong have happen <br/> ");
out.println( "\n******SQLException catch********\n ");
while(ex!=null)
{ out.println( "SQLState: "+ex.getSQLState());
out.println( "Message: "+ex.getMessage());
out.println( "Vendor: "+ex.getErrorCode());
ex= ex.getNextException();
out.println( " ");
}
}
%>
<%
out.println( " <br/> 如果你能看到这里,就那行了 <br/> ");
%>
</BODY>
</HTML>
谁有做过的连数据库的事例程序代码。给几个参考下 jsp 今天刚开始看。
shgh800@163.com 谢谢了先
------解决方案--------------------估计是你数据源培植的问题 配置了以后TEST下
------解决方案--------------------看着是数据源配置或驱动问题,用JDBC吧,不要用ODBC