android studio中的Sqlserver连接

时间:2015-10-29 06:39:42

标签: android

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/

因此http://hizliresim.com/qRdojd

0 个答案:

没有答案