Two Laptop Bag*
The moose likes JDBC and the fly likes Newbie Java MySql question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Newbie Java MySql question" Watch "Newbie Java MySql question" New topic

Newbie Java MySql question

Scott Matthews
Ranch Hand

Joined: Jun 28, 2001
Posts: 36
I am new to java (about 6 months). I downloaded the MySql and am running the Server (MySqlD) on my Win98 computer. I can run MySql and all works fine when I input commands by hand. I want to now create a java program that will open an existing database and insert some records.
Can anyone provide a quick source code snippet that would handle opening a database and "sending" the database a SQL statement?

Thanks for your time.
Dorj Galaa
Ranch Hand

Joined: May 29, 2001
Posts: 113
import java.sql.*;
public class MySQL
public static void main(String args[])
Connection mysql=DriverManager.getConnection("jdbc:mysql://");
catch(Exception e)
download MySQL jdbc driver

Senior software engineer
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
subject: Newbie Java MySql question
Similar Threads
mysql-connector-java-5.0.4-bin.jar for mysql server 5.1 version
MySQL Connection in Eclipse 3.2
Creating Database
which is better?
MYSQL Exception