Tuesday, July 27, 2010

Setting Up MySQL/JDBC Driver on Ubuntu

So that we can not connect to the database mysql,we need to download :
sudo apt-get install libmysql-java
To use the mysql connector java,we need to download in 
Once we do we download the configuration in eclipse,like this :
  1. Select Project Properties > Java Build Path
  2. Select Libries tab
  3. Click Add External Jars
  4. Choose the jar file, in this case mysql-connector-java.java
Once you’re done, you can test the connection using the following snippet:

 package com.andia.oop;

 * connect to database mysqls
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class ConnectionDatabases {
    public static void main(String[] args) throws SQLException {

        String url = "jdbc:mysql://localhost/datapribadi";
        String user = "root";
        String pass = "dendy";

            Connection con = DriverManager.getConnection(url, user, pass);
                    .println("anda telah connect dengan database datapribadi");


Ok.please..using mysql in java.

No comments: