APP quits unexpectedly on your smartphone

1

Below is the code and logs. I try to run, but it always closes the app unexpectedly. It closes without showing the error image or inserts into the database.

 package...

imports

public class Cadastro extends AppCompatActivity
{
    EditText txtNome, txtEmail, txtSenha, txtRepeteSenha;
    Button btnCadastrar;
    ProgressBar progressBar;
    ConnectionClass connectionClass;

    @Override
    protected void onCreate (Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_cadastro);
        connectionClass = new ConnectionClass();
        txtNome = findViewById(R.id.name);
        txtEmail = findViewById(R.id.email);
        txtSenha = findViewById(R.id.senha);
        txtRepeteSenha = findViewById(R.id.key_again);
        btnCadastrar = findViewById(R.id.cadastrar);
        progressBar = findViewById(R.id.progressBar);

        btnCadastrar.setOnClickListener(new View.OnClickListener(){
            @Override
            public void onClick (View v){
                salvarBanco();
            }
        });
    }

    public Connection connectionBD(){
        Connection connection = null;
        String url = "jdbc:jtds:sqlserver://meu_ip:1433;databaseName=meu_banco;user=meu_user_banco;password=minha_senha_banco;";
        try {
            StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
            StrictMode.setThreadPolicy(policy);
            Class.forName("net.sourceforge.jtds.jdbc.Driver").newInstance();
            connection = DriverManager.getConnection(url);
            Log.e("Script", "teste");
            Toast.makeText(getApplicationContext(),"Sucesso!",Toast.LENGTH_SHORT).show();
        }catch (Exception e){
            Toast.makeText(getApplicationContext(),e.getMessage(),Toast.LENGTH_SHORT).show();
        }
        return connection;
    }

    public void salvarBanco(){
        String query = "INSERT INTO Usuario(email, nome, senha) VALUES(?,?,?)";
        try{
            PreparedStatement preparedStatement = connectionBD().prepareStatement(query);
            preparedStatement.setString(1,txtEmail.getText().toString());
            preparedStatement.setString(2,txtNome.getText().toString());
            preparedStatement.setString(3,txtSenha.getText().toString());
            preparedStatement.executeUpdate();
        }catch (Exception e){
            Toast.makeText(getApplicationContext(),e.getMessage(),Toast.LENGTH_SHORT).show();
        }
    }
}

The error:

10-03 17:13:42.954 27329-27329/com.example.paulo.apptecnico E/AndroidRuntime: FATAL EXCEPTION: main
        Process: com.example.paulo.apptecnico, PID: 27329
        java.lang.VerifyError: net/sourceforge/jtds/jdbc/TdsCore
            at net.sourceforge.jtds.jdbc.JtdsConnection.<init>(JtdsConnection.java:359)
            at net.sourceforge.jtds.jdbc.Driver.connect(Driver.java:184)
            at java.sql.DriverManager.getConnection(DriverManager.java:179)
            at java.sql.DriverManager.getConnection(DriverManager.java:144)
            at com.example.paulo.apptecnico.Cadastro.connectionBD(Cadastro.java:55)
            at com.example.paulo.apptecnico.Cadastro.salvarBanco(Cadastro.java:67)
            at com.example.paulo.apptecnico.Cadastro$1.onClick(Cadastro.java:41)
            at android.view.View.performClick(View.java:4740)
            at android.view.View$PerformClick.run(View.java:19383)
            at android.os.Handler.handleCallback(Handler.java:733)
            at android.os.Handler.dispatchMessage(Handler.java:95)
            at android.os.Looper.loop(Looper.java:146)
            at android.app.ActivityThread.main(ActivityThread.java:5679)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:515)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1291)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1107)
            at dalvik.system.NativeStart.main(Native Method)
    10-03 17:13:43.284 853-27985/? E/android.os.Debug: !@Dumpstate > sdumpstate -k -t -z -d -o /data/log/dumpstate_app_error
    10-03 17:13:44.904 853-969/? E/ViewRootImpl: sendUserActionEvent() mView == null
    10-03 17:13:45.014 240-240/? E/SMD: DCD ON
    10-03 17:13:45.134 28010-28010/com.example.paulo.apptecnico E/dalvikvm: Could not find class 'android.support.v4.view.ViewCompat$OnUnhandledKeyEventListenerWrapper', referenced from method android.support.v4.view.ViewCompat.addOnUnhandledKeyEventListener
    10-03 17:13:45.134 28010-28010/com.example.paulo.apptecnico E/dalvikvm: Could not find class 'android.view.WindowInsets', referenced from method android.support.v4.view.ViewCompat.dispatchApplyWindowInsets
    10-03 17:13:45.144 28010-28010/com.example.paulo.apptecnico E/dalvikvm: Could not find class 'android.view.WindowInsets', referenced from method android.support.v4.view.ViewCompat.onApplyWindowInsets
    10-03 17:13:45.144 28010-28010/com.example.paulo.apptecnico E/dalvikvm: Could not find class 'android.view.View$OnUnhandledKeyEventListener', referenced from method android.support.v4.view.ViewCompat.removeOnUnhandledKeyEventListener
    10-03 17:13:45.144 28010-28010/com.example.paulo.apptecnico E/dalvikvm: Could not find class 'android.support.v4.view.ViewCompat$1', referenced from method android.support.v4.view.ViewCompat.setOnApplyWindowInsetsListener
    10-03 17:13:45.454 28010-28010/com.example.paulo.apptecnico E/SpannableStringBuilder: SPAN_EXCLUSIVE_EXCLUSIVE spans cannot have a zero length
    10-03 17:13:45.454 28010-28010/com.example.paulo.apptecnico E/SpannableStringBuilder: SPAN_EXCLUSIVE_EXCLUSIVE spans cannot have a zero length
    
asked by anonymous 03.10.2018 / 22:16

1 answer

0

I switched to a connection via a connector, built with PHP and Volley, but it does not even send, as it closes the application as soon as I press the submit button.

    
31.10.2018 / 22:13