PostgreSQL Database not connecting to Android app

40
December 01, 2020, at 2:00 PM

My database is running fine because I tested it using Eclipse with simple Java code that just connects and reports back success or fail. I connect fine.I can even read and write to it there. Now, when I try to do the same thing in Android Studio,the connection fails. I created a lib folder for the app and put all the extra .jar files there including the JDBC connector for Postgresql that I used in Eclipse.

public class MainActivity extends AppCompatActivity {
private TextView f;
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    f = (TextView) findViewById(R.id.textViewa);
    java.sql.Connection conn = null;
    try {
        final String mysqlConnUrl = "jdbc:postgresql://suleiman.db.elephantsql.com:5432/rwvwaocz";
        try {
            Class.forName("org.postgresql.Driver");
            Properties props = new Properties();
            props.setProperty("user", "postgres");
            props.setProperty("password", "mitko9670");
            conn = DriverManager.getConnection(mysqlConnUrl, "postgres","mitko9670");
            f.setText("SUCCESS");
        } catch (NoClassDefFoundError i) {
            i.printStackTrace();
        }
        conn.close();
    } catch (Exception ex) {
        f.setText("No");
        ex.printStackTrace();
    }
}

}

I tried with but none work. Can you give me an example of connecting to the database. Apart from the jar for Postgresql, is there anything else to put

READ ALSO
Python Pynput release and press

Python Pynput release and press

Hi i want to make a script that prints "Released" when i release my left mouse buttonThe same for "pressed"

64
How do I create a function parameter (variable) for the answers to an inquirer.prompt question in javascript? MySQL is also involved

How do I create a function parameter (variable) for the answers to an inquirer.prompt question in javascript? MySQL is also involved

How do I create a function parameter (variable) for the answers to an inquirerprompt question in JavaScript? I know how to do this without using variables, but to make my function addToTable easier to use throughout my code, I wanted to use parameters

100
socket-io: How to chat separately between chatroom creator and other user and save them on database

socket-io: How to chat separately between chatroom creator and other user and save them on database

I made a chat app, where users can join in a chatroom and when a message is sent, I am saving those messages to db

48
activate next and privous button of owl-slider using jquery

activate next and privous button of owl-slider using jquery

hello i am new in laravel i am displaying product on silder it works fine but my next and privous button is not workingHow can i work on next and previous button its customize code

77