public void Baglan()
{
String url = "jdbc:jtds:sqlserver://192.168.1.12:1433;DatabaseName=xxxx_";
String driver = "net.sourceforge.jtds.jdbc.Driver";
String userName = "halit";
String password = "wTWfw42FAax*";
// Declare the JDBC objects.
Connection con = null;
Statement stmt = null;
ResultSet rs = null;
try
{
Class.forName(driver);
con = DriverManager.getConnection(url, userName, password);
String SQL = "select * from DENEME";
stmt = con.createStatement();
rs = stmt.executeQuery(SQL);
while (rs.next())
{
AlertDialog alertMessage = new AlertDialog.Builder(this).create();
alertMessage.setTitle("Mesaj Başlığı");
alertMessage.setMessage(rs.getString(0));
alertMessage.show();
}
}
catch(Exception ex)
{
AlertDialog alertMessage = new AlertDialog.Builder(this).create();
alertMessage.setTitle("Mesaj Başlığı");
alertMessage.setMessage(ex.getMessage().toString());
alertMessage.show();
}
}
如何使用SQLServer jtds访问android studio? 添加图书馆:http://sourceforge.net/projects/jtds/files/jtds/1.2.1/