私のアンドロイドプロジェクトでJDBCを使用してデータベースとの接続を作成しようとしています。私はjarをインポートして、アクティビティで接続を作成するというチュートリアルに従っています。私は方法の参照に取得しようとした場合アンドロイドcreateStatement()は存在しませんか?
「)のcreateStatement(」すべてはOKですが、接続文の中で、私はエラー
は、メソッドを解決できません取得し、それは
語りますは
にこの方法を行くためにdeclerationを見つけることができない私は、インポートしたjarファイルから来ていますか? (jtds-1.3.1) ここに他に何かがありますか?
@Override protected String doInBackground(String... params) { Connection con; String usernam = params[0]; String passwordd = params[1]; if(usernam.trim().equals("")|| passwordd.trim().equals("")) z = "Please enter Username and Password"; else { try { con = connectionclass(un, pass, db, ip); // Connect to database if (con == null) { z = "Check Your Internet Access!"; } else { // Change below query according to your own database. String query = "select * from owner where mail = '" + usernam.toString() + "' and password = '"+ passwordd.toString() +"' "; Statement stmt = con.createStatement(); ResultSet rs = stmt.executeQuery(query); if(rs.next()) { z = "Login successful"; isSuccess=true; con.close(); } else { z = "Invalid Credentials!"; isSuccess = false; } } } catch (Exception ex) { isSuccess = false; z = ex.getMessage(); } } return z; } } @SuppressLint("NewApi") public Connection connectionclass(String user, String password, String database, String server) { StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build(); StrictMode.setThreadPolicy(policy); Connection connection = null; String ConnectionURL = null; try { Class.forName("net.sourceforge.jtds.jdbc.Driver"); ConnectionURL = "jdbc:jtds:sqlserver://" + server + database + ";user=" + user+ ";password=" + password + ";"; connection = (Connection) DriverManager.getConnection(ConnectionURL); } catch (SQLException se) { Log.e("error here 1 : ", se.getMessage()); } catch (ClassNotFoundException e) { Log.e("error here 2 : ", e.getMessage()); } catch (Exception e) { Log.e("error here 3 : ", e.getMessage()); } return connection; }
独自のConnectionクラスはありますか? – Aryan
ええ、私が投稿したこのコードは接続クラスの中にあります。 – Kzaf