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
Controller Advice bean not instantiated at proper order in Spring Boot 2.4
What should I enter to the connection string to connect my NodeJS application to a MongoDB server?
Unable to use Computed Property Values with Dots - Unable to Set as String - JS
Hi i want to make a script that prints "Released" when i release my left mouse buttonThe same for "pressed"
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
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
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