sql server - Connect mssql to android app -
i'm trying connect android app mssql database. got exception when im trying connect. have checked in debug mode , goes class.forname exception catch here code .
protected void onstart() { try { // load sqlserverdriver class, build // connection string, , connection class.forname("com.microsoft.sqlserver.jdbc.sqlserverdriver"); string connectionurl = "jdbc:sqlserver://xxx\\xxxxx:1433;" + "database=xxxx;" + "user=xxxx;" + "password=*****"; connection con = drivermanager.getconnection(connectionurl); system.out.println("connected."); // create , execute sql statement returns data. string sql = "select count(*) xxxxxx"; statement stmt = con.createstatement(); resultset rs = stmt.executequery(sql); textview tv=(textview) findviewbyid(r.id.textview1); tv.settext((charsequence) rs); // iterate through data in result set , display it. while (rs.next()) { system.out.println(rs.getstring(1) + " " + rs.getstring(2)); } } catch (exception e) { e.printstacktrace(); } super.onstart(); }
thats not possible, android suffer limit of bandwidth can't talk external databases, , create simple web page (php) return need mysql database , parse xml file or maybe json because it's better now, can call php page android application , json file.
this tuto explain well:
http://www.androidhive.info/2012/05/how-to-connect-android-with-php-mysql/
good luck :)
Comments
Post a Comment