Click here to Skip to main content
15,893,161 members

Comments by akira32 (Top 1 by date)

akira32 24-Jul-16 21:27pm View    
I had added the network permissions and add jtds-1.3.1.jar to the libs driectory.

uses-permission android:name="android.permission.INTERNET"
uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"

But when I getConnection, it appears the exception message(android.os.NetworkOnMainThreadException) at

DriveManager.getConnection. Does somebody know what I lose to set?

protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
findViews();
}

private void findViews()
{

try {
Class.forName("net.sourceforge.jtds.jdbc.Driver").newInstance();
con = DriverManager.getConnection(URL, USER, PASSWORD);
}
catch (Exception e)
{
Log.w("Error connection","" + e.getMessage());

}