android JDBC无法正常工作 [英] android JDBC not work

查看:86
本文介绍了android JDBC无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好吧

i有这个代码和java一起使用很多人在android下使用是工作

但是我不能工作

和show消息

没有合适的驱动程序



hi everyone
i have this code working with java and many people used under android is work
but with me not work
and show message
no suitable driver

public void dbConnect(String db_connect_string,
               String db_userid,
               String db_password)
      {

        String x="  ";
         try {
             try{
                 Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
             }
             catch (Exception e) {
           x +="  1 ";
           }
             x+= "  befor cpm ";
            Connection conn = DriverManager.getConnection(db_connect_string,
                     db_userid, db_password);
            x+= "  conne ";
            System.out.println("connected");
            Statement statement = conn.createStatement();
            String queryString = "select * from A_Users";
            Cursor rs = (Cursor) statement.executeQuery(queryString);

            while (rs.moveToNext()) {
              // System.out.println();
               x+=rs.getString(2);
            }
            conn.close();
         } catch (SQLException e) {
            e.printStackTrace();
            x +=e.getMessage() + "  mostafa";
         }

         EditText tex= (EditText) findViewById(R.id.editText1);
         tex.setText(x);


      }



使用eclipse和上一版本有什么问题

感谢您的帮助



已添加代码块[/编辑]


what is a problem im using eclipse with last version
thanks for any help

Code block added[/Edit]

推荐答案

否当驱动程序未加载或连接字符串错误时,会显示合适的驱动程序错误。可能是后者,但肯定也可能是前者,因为你在加载驱动程序时正在吃异常。
The "no suitable driver" error shows up when either the driver isn''t loaded or the connection string is wrong. Could be the latter, but certainly could be the former as well because you are eating the exception when it loads the driver.


这篇关于android JDBC无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆