Click here to Skip to main content
15,890,123 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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

Java
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);


      }

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

[Edit]Code block added[/Edit]
Posted
Updated 20-Dec-12 3:20am
v2
Comments
joshrduncan2012 20-Dec-12 9:26am    
What kind of output are you getting that leads you to believe that it's not working properly?
Mostafa Elsadany 20-Dec-12 9:28am    
the problem not in output he not connect to get output
so the problem in connection
but the code of connection is working under java apps
thanks for help

1 solution

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.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900