Home > Mobile >  About using jump connect to the database error
About using jump connect to the database error

Time:10-02

W/System. Err: Java. SQL. SQLNonTransientConnectionException: Could not create connection to the database server.
At com. Mysql. Cj. JDBC. Exceptions. SQLError. CreateSQLException (SQLError. Java: 110)
At com. Mysql. Cj. JDBC. Exceptions. SQLError. CreateSQLException (SQLError. Java: 97)
At com. Mysql. Cj. JDBC. Exceptions. SQLError. CreateSQLException (SQLError. Java: 89)
W/System. Err: ats com. Mysql. Cj. JDBC. Exceptions. SQLError. CreateSQLException (SQLError. Java: 63)
At com. Mysql. Cj. JDBC. ConnectionImpl. ConnectOneTryOnly (ConnectionImpl. Java: 1000)
At com. Mysql. Cj. JDBC. ConnectionImpl. CreateNewIO (ConnectionImpl. Java: 817)
At com. Mysql. Cj. JDBC. ConnectionImpl. & lt; init> (ConnectionImpl. Java: 447)
At com. Mysql. Cj. JDBC. ConnectionImpl. GetInstance (ConnectionImpl. Java: 237)
At com. Mysql. Cj. JDBC. NonRegisteringDriver. Connect (NonRegisteringDriver. Java: 199)
The at Java. SQL. DriverManager. GetConnection (DriverManager. Java: 569)
The at Java. SQL. DriverManager. GetConnection (DriverManager. Java: 219)
At com. Windows. Myapp. DBUtil. Getconn (DBUtil. Java: 34)
At com. Windows. Myapp. Getimage. ReadDB2Image (42) Obtain. Java:
At com. Windows. Myapp. WindowsActivity. OnCreate (WindowsActivity. Java: 34)
W/System. Err: at the android app. Activity. PerformCreate (7136) Activity. Java:
. An android app. Activity. PerformCreate (7127) Activity. Java:
. An android app. Instrumentation. CallActivityOnCreate (1271) Instrumentation. Java:
W/System. Err: at the android app. ActivityThread. PerformLaunchActivity (ActivityThread. Java: 2893)
. An android app. ActivityThread. HandleLaunchActivity (ActivityThread. Java: 3048)
An android. App. Servertransaction. LaunchActivityItem. Execute (LaunchActivityItem. Java: 78)
An android. App. Servertransaction. TransactionExecutor. ExecuteCallbacks (TransactionExecutor. Java: 108)
An android. App. Servertransaction. TransactionExecutor. Execute (TransactionExecutor. Java: 68)
W/System. Err: at the android app. ActivityThread $H.h andleMessage (ActivityThread. Java: 1808)
An android. OS. Handler. DispatchMessage (Handler. Java: 106)
. An android OS. Stars. Loop (193). Which Java:
. An android app. ActivityThread. Main (6669) ActivityThread. Java:
W/System. Err: at Java lang. Reflect. Method. Invoke (Native Method)
At com. Android. Internal. OS. RuntimeInit $MethodAndArgsCaller. Run (493) RuntimeInit. Java:
W/System. Err: ats com. Android. Internal. OS. ZygoteInit. Main (ZygoteInit. Java: 858)
W/System. Err: under Caused by: android.os.Net workOnMainThreadException
. An android OS. StrictMode $AndroidBlockGuardPolicy. OnNetwork (StrictMode. Java: 1513)
At java.net.AbstractPlainSocketImpl.doConnect AbstractPlainSocketImpl. Java: (389)
At java.net.AbstractPlainSocketImpl.connectToAddress AbstractPlainSocketImpl. Java: (230)
At java.net.AbstractPlainSocketImpl.connect AbstractPlainSocketImpl. Java: (212)
At java.net.SocksSocketImpl.connect SocksSocketImpl. Java: (436)
At java.net.Socket.connect (621) Socket. Java:
W/System. Err: ats com. Mysql. Cj. Protocol. StandardSocketFactory. Connect (StandardSocketFactory. Java: 155)
At com. Mysql. Cj. Protocol. A.N ativeSocketConnection. Connect (NativeSocketConnection. Java: 65)
At com. Mysql. Cj. NativeSession. Connect (NativeSession. Java: 150)
At com. Mysql. Cj. JDBC. ConnectionImpl. ConnectOneTryOnly (ConnectionImpl. Java: 947)
. 24 more






CodePudding user response:

Public class WindowsActivity extends AppCompatActivity {
Private ImageView mIv1;
Private Button Btn1;

@ Override
Protected void onCreate (Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
The setContentView (R.l ayout. Activity_windows);
Btn1=the findViewById (R.i db t_01);

MIv1=the findViewById (R.i d.i v_01);

The Getimage. ReadDB2Image ();//this method is to connect to the database

CodePudding user response:

Can separate the main method is used to connect to the database connection is successful, but on the APP will connect failed

CodePudding user response:

There are bosses know how to solve? Kneel to beg

CodePudding user response:

Because android is not allowed to request for network in the main thread, so you need to the connection of the data code on the child thread that executes

CodePudding user response:

m - reference 4 floor oj response:
because android is not allowed to request for network in the main thread, so you need to the connection of the data code on the child thread that executes
I try
  • Related