How i can connect and acess to a database in host server

  • Replies:0
Hélder Silva
  • Forum posts: 1

Sep 1, 2012, 11:19:29 AM via Website

i am using a pc server online with sqlserver2008. and i want connect and access to my database"MaisRitmo2013" which is attached in my sqlserver2008 from management studio with my android.

i am using this code to example:

String driver = "net.sourceforge.jtds.jdbc.Driver";
String userName = "sa";
String password = "l0gitech";
int portNumber = 1433;
String serverName = "localhost";
Class.forName(driver).newInstance();
//test = com.microsoft.sqlserver.jdbc.SQLServerDriver.class;
// String connString = "jdbc:jtds:sqlserver://server_ip_address :1433/DBNAME;encrypt=false;user=xxxxxxxxx;password=xxxxxxxx;instance=SQLEXPRESS;";
// String connString = "jdbc:jtds:sqlserver://192.168.1.11:1433/MaisRitmo2013;encrypt=false;user=sa;password=l0gitech;instance=HELDERSILVA-PC\\SERVER2008;";

Properties connectionProps = new Properties();
connectionProps.put("user", userName);
connectionProps.put("password", password);

conn = DriverManager.getConnection("jdbc:jtds:sqlserver://" +serverName +":" + portNumber + "/", connectionProps);


// conn = DriverManager.getConnection(connString,username,password);
Log.w("Connection","open");
connectext.setText("Open");

can anyone help me doing this? sry my bad english

Reply