运行的时候报错 no suitable driver
这是怎么回事情啊?>
    driver 应该没问题的,我用CLASS.FORNAME();这样的硬连接方式都能通的
但改成数据源 就会报那个错
   大家出出注意啊....

解决方案 »

  1.   

    try{ 
       InitialContext cxt=new InitialContext();
       DataSource ds=(DataSource)cxt.lookup("jdbc/test1DS");
       Connection conn=ds.getConnection();
       Statement sta=conn.createStatement();
        ResultSet rs=sta.executeQuery("select * from table1");    
        while(rs.next())
           {
           String na=rs.getString("name");
           String nu=rs.getString("code");
          out.print("dfasdfa"+na+":"+nu);
          }
       
        }
        catch(Exception e)
        {
        out.print("fail");
       System.out.print(e.toString());
        }
      

  2.   

    在配置数据源的时候 数据源测试是success
      所以我认为数据源是能够找到的
    Connection conn=ds.getConnection();应该就在获取连接这一步上,发生异常了:no suitable driver....
      

  3.   

    //数据库在ODBC中指定
    import java.sql.*;
    public class db_test {
    public static void main(String []args) throws SQLException,ClassNotFoundException
    {
    String dburl="jdbc:odbc:XJP";
    String user="";
    String password="";
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    Connection c=DriverManager.getConnection(dburl,user,password);
    Statement s=c.createStatement();
    ResultSet r=s.executeQuery("SELECT NAME From student");
    while(r.next())
    {
    System.out.println(r.getString("NAME"));
    System.out.println(r.getString(1));
    }
    s.close();
    }
    }试试
      

  4.   

    谢谢楼上哈
      我试过用ODBC连接  是可以成功的哈
     我现在就是想用JDBC连接啊
         
      为什么driver 会有问题呢?
     会不会是 我用的连接用户名字有问题啊
    我的所有表都属于dbo,没有属于我用于连接的那个用户的....
      

  5.   

    其实我在网上查了 一些 关于no suitable driver的解决办法
       但根本不行,
    郁闷啊......
      

  6.   

    应该还是配置问题,如果你说的那一句出错的话。
    你用的什么数据库,什么jdbc都贴出来看看。
      

  7.   

    你的数据源配置有问题:
    找不到 jdbc/test1DS。
      

  8.   

    借光:路过的各位,帮忙看看这几个帖子,看怎么解决;)谢谢啦!关于客户端页面从数据库中读取大量图片的问题
    http://community.csdn.net/Expert/TopicView3.asp?id=4816106乱码还原问题!
    http://community.csdn.net/Expert/TopicView3.asp?id=4813786关于javabean反射代理的问题
    http://community.csdn.net/Expert/TopicView3.asp?id=4813935