user1092042
user1092042

Reputation: 1295

Update mysql database from java

I have a database which i have created using phpmyadmin. I need this database to be update programmatically using values i get from a java program. How would i go about doing this.

Upvotes: 0

Views: 517

Answers (2)

Andrzej Doyle
Andrzej Doyle

Reputation: 103837

Simple database access in Java is achieved via JDBC. The exact commands you'd need to use depend on what sort of queries you want to execute, but any half-decent tutorial should cover both select and insert/update statements.

I'd recommend starting with Sun's JDBC Basics tutorial, and going from there.

If you have any specific points you're stuck on after following the tutorial, I'd recommend posting a follow-up question showing what you've tried to do, and why it's not working. However asides from perhaps getting an environment set up, JDBC isn't too tricky to use.

(Do remember to close your resources in a finally block though!)

Upvotes: 2

Anurag Ramdasan
Anurag Ramdasan

Reputation: 4340

i think this might work. not very sure

Class.forName("com.mysql.jdbc.Driver");
connection = DriverManager.getConnection("jdbc:mysql://localhost/login" ,"root","");
statement = connection.createStatement();

Upvotes: -1

Related Questions