• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Connect android to remote SQL Server 2008

emad11

Lurker
Aug 24, 2014
2
0
I'm new in android programming
I want to connect to the remote sql server 2008 but when I run the project it return this message : "com.microsoft.sqlserver.jdbc.SQLServerDriver"
**I think this error is for my connection string.**
my c# connection string is :

PHP:
string connectionStr = "Data Source=arabbros.com\sql2008,2008;Initial Catalog=arabbros1;User ID=emad11;Password=112233"

now I want to change it to java connection string for remote sql server
and my code is :

public void run()
{
String connectionUrl= "jdbc:sqlserver://arabbros.com:1433;instance=sql2008,2008;databaseName=arabbros1;integ ratedSecurity=true;";
Connection con = null;
Statement stmt = null;
try 
{
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver").newInstance();
con = DriverManager.getConnection(connectionUrl,"emad11","112233");
stmt = con.createStatement();
ResultSet reset = stmt.executeQuery("select * from Table1");
txt.setText(reset.getString("Emd"));
con.close();
}
catch (Exception e) 
{
txt.setText(e.getMessage());
}
}
 

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones