Error connecting android to SQL -
Iam is writing an app that should communicate with the MySQL database. Ive added the class mysql to the driver .. *. Jar is successfully loaded for the project and also if I try to connect to the databse I get the following error:
10-09 21: 01: 01.626 27334-27334 / Dd.edope.quizmasters d / libcï¹ ?? [Net] getaddrinfo hostname mysql.1freehosting.com, servname NULL, ai_family 0 10-09 21: 01: 01.626 27334-27334 / dd.edope.quizmasters w / system. ?
com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Could not make connection to database server.
My code here:
Private static final string url = "jdbc: mysql: //mysql.1freehosting.com/u741539452_quiz"; Private Stable Last String User = "...."; Private Stable Last String Pass = "...."; Public Zero Test DB () {Text to TV = (TextView) Routview.FindvibIID (RID. Questation); Try {class.forName ("com.mysql.jdbc.Driver"); Connection con = DriverManager.getConnection (url, user, pass); / * System.out.println ("database connection success"); * / String result = "database connection success \ n"; Description st = con.createStatement (); Results set rs = st.executeQuery ("select frage" *); ResultsetMetaData rsmd = rs.getMetaData (); // while (rsnext ()) {// result = = rsmd.getColumnName (1) + ":" + rs.getInt (1) + "\ n"; // result + = rsmd.getColumnName (2) + ":" + rs.getString (2) + "\ n"; // result + = rsmd.getColumnName (3) + ":" + rs.getString (3) + "\ n"; //} tv.setText (Results); } Hold (exception e) {e.printStackTrace (); Tv.setText (e.toString ()); }} Can this be the wrong URL for the database? On the homepage of 1freehosting.com, it is said that the host address is "mysql.1freehosting.com" but I am not sure that this is the correct URL for the DB connection.
Any ideas to handle? Thanks a lot.
Most likely you can not access this database from the remote. You can access it only by the script running on that server. If this is the case, then you can create a webservice that creates database queries. Your app then makes an HTTP request for that service.
Comments
Post a Comment