lundi 29 décembre 2014

Connecting android app to online mysql databse


Vote count:

0




hi iam new to android development iam currently working on an android app that needs to connect to an online mysql database. I had experience in java application development in netbeans,I used the following code in netbeans to connect to an sql server by using jdbc driver....



import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;

import net.sourceforge.jtds.jdbc.*;

public void query2()
{
Log.i("Android"," MySQL Connect Example.");
Connection conn = null;
try {
String driver = "net.sourceforge.jtds.jdbc.Driver";
Class.forName(driver).newInstance();
//test = com.microsoft.sqlserver.jdbc.SQLServerDriver.class;
String connString = "jdbc:jtds:http://sqlserverserver_ip_address :1433/DBNAME;encrypt=fasle;user=xxxxxxxxx;password=xxxxxxxx;instance=SQLEXPRESS;";
String username = "xxxxxx";
String password = "xxxxxxxxxx";
conn = DriverManager.getConnection(connString,username,password);
Log.w("Connection","open");
Statement stmt = conn.createStatement();
ResultSet reset = stmt.executeQuery("select * from TableName");

//Print the data to the console
while(reset.next()){
Log.w("Data:",reset.getString(3));
// Log.w("Data",reset.getString(2));
}
conn.close();

} catch (Exception e)
{
Log.w("Error connection","" + e.getMessage());
}


but in android iam stuck at nowhere i don't know any thing about it,so can please any one write my code for a correspoding android application so that i can understand th difference ....any help would be apricited...



asked 30 secs ago







Connecting android app to online mysql databse

Aucun commentaire:

Enregistrer un commentaire