Setting up Mysql-JDBC driver in ubuntu

Setting  up Mysql-jdbc driver involved in following steps:

  1. check updates by this command:
    sudo apt-get update
  2. install mysql and mysql secure:
  3. sudo apt-get install mysql mysql-server
    sudo mysql_secure_installation
  4. now setting classpath in Bashrc file:  by command nano ~/.bashrc
    export CLASSPATH=$CLASSPATH:/usr/share/java/mysql-connector-java.jar
  5. then write down this code/*
    Setting up Mysql-JDBC driver in ubuntu
    @author:Mitra N Mishra
    */
    import java.sql.Connection;
    import java.sql.DriverManager;
     
    class JDBCTest {
     
     private static final String url = "jdbc:mysql://localhost?useSSL=false";
     
     private static final String user = "root";
     
     private static final String password = "12345";
     
     public static void main(String args[]) {
     try {
     Connection con = DriverManager.getConnection(url, user, password);
     System.out.println("Success");
     
     } catch (Exception e) {
     e.printStackTrace();
     }
     }
    }

     

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s