Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save lehungio/7c4fcbb7e6e6847883471569b5d57d7a to your computer and use it in GitHub Desktop.

Select an option

Save lehungio/7c4fcbb7e6e6847883471569b5d57d7a to your computer and use it in GitHub Desktop.

Revisions

  1. @craigvantonder craigvantonder revised this gist Mar 18, 2017. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions connectorj-mysql-integration.md
    Original file line number Diff line number Diff line change
    @@ -1,11 +1,13 @@
    Read through: https://www.digitalocean.com/community/tutorials/how-to-install-java-with-apt-get-on-ubuntu-16-04

    Then install Oracle Java 8:

    sudo add-apt-repository ppa:webupd8team/java
    sudo apt-get update
    sudo apt-get install oracle-java8-installer

    Read through: https://help.ubuntu.com/community/JDBCAndMySQL

    Then install the connector driver:

    sudo apt-get install libmysql-java
  2. @craigvantonder craigvantonder revised this gist Mar 18, 2017. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions connectorj-mysql-integration.md
    Original file line number Diff line number Diff line change
    @@ -1,12 +1,12 @@
    Read through: https://www.digitalocean.com/community/tutorials/how-to-install-java-with-apt-get-on-ubuntu-16-04

    Then install Oracle Java 8:

    sudo add-apt-repository ppa:webupd8team/java
    sudo apt-get update
    sudo apt-get install oracle-java8-installer

    Install the connector driver - https://help.ubuntu.com/community/JDBCAndMySQL:
    Read through: https://help.ubuntu.com/community/JDBCAndMySQL
    Then install the connector driver:

    sudo apt-get install libmysql-java

    @@ -67,7 +67,7 @@ If you get the error:

    Check out: http://stackoverflow.com/questions/36746677/table-performance-schema-session-variables-doesnt-exist

    I needed to run:
    I personally needed to run:

    mysql_upgrade -u root -p --force

  3. @craigvantonder craigvantonder revised this gist Mar 18, 2017. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion connectorj-mysql-integration.md
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,6 @@
    Install Oracle Java 8 - https://www.digitalocean.com/community/tutorials/how-to-install-java-with-apt-get-on-ubuntu-16-04:
    Read through: https://www.digitalocean.com/community/tutorials/how-to-install-java-with-apt-get-on-ubuntu-16-04

    Then install Oracle Java 8:

    sudo add-apt-repository ppa:webupd8team/java
    sudo apt-get update
  4. @craigvantonder craigvantonder revised this gist Mar 18, 2017. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion connectorj-mysql-integration.md
    Original file line number Diff line number Diff line change
    @@ -72,4 +72,6 @@ I needed to run:
    And then:

    echo "# JDBC Connection error
    performance_schema=ON" >> /etc/mysql/mysql.conf.d/mysqld.cnf
    performance_schema=ON" >> /etc/mysql/mysql.conf.d/mysqld.cnf

    You can make use of this to setup a data pipeline between MySQL and Amazon ElasticService by following these instructions here: https://gist.github.com/craigvantonder/8566c6992b930e7d2ac2520e18516e4d
  5. @craigvantonder craigvantonder renamed this gist Mar 17, 2017. 1 changed file with 0 additions and 0 deletions.
  6. @craigvantonder craigvantonder revised this gist Mar 17, 2017. No changes.
  7. @craigvantonder craigvantonder revised this gist Mar 16, 2017. 1 changed file with 8 additions and 6 deletions.
    14 changes: 8 additions & 6 deletions mysql-connectorj-integration.md
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,8 @@
    Install Java SDK and Runtime environment - https://www.digitalocean.com/community/tutorials/how-to-install-java-with-apt-get-on-ubuntu-16-04:
    Install Oracle Java 8 - https://www.digitalocean.com/community/tutorials/how-to-install-java-with-apt-get-on-ubuntu-16-04:

    sudo apt-get install default-jdk
    sudo add-apt-repository ppa:webupd8team/java
    sudo apt-get update
    sudo apt-get install oracle-java8-installer

    Install the connector driver - https://help.ubuntu.com/community/JDBCAndMySQL:

    @@ -60,13 +62,13 @@ Run the test:
    If you get the error:

    Exception in thread "main" com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table 'performance_schema.session_variables' doesn't exist

    Check out: http://stackoverflow.com/questions/36746677/table-performance-schema-session-variables-doesnt-exist
    I needed to run:

    I needed to run:

    mysql_upgrade -u root -p --force

    And then:

    echo "# JDBC Connection error
  8. @craigvantonder craigvantonder revised this gist Mar 16, 2017. No changes.
  9. @craigvantonder craigvantonder revised this gist Mar 16, 2017. 1 changed file with 16 additions and 1 deletion.
    17 changes: 16 additions & 1 deletion mysql-connectorj-integration.md
    Original file line number Diff line number Diff line change
    @@ -55,4 +55,19 @@ Compile the test:

    Run the test:

    java DBDemo
    java DBDemo

    If you get the error:

    Exception in thread "main" com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table 'performance_schema.session_variables' doesn't exist

    Check out: http://stackoverflow.com/questions/36746677/table-performance-schema-session-variables-doesnt-exist

    I needed to run:

    mysql_upgrade -u root -p --force

    And then:

    echo "# JDBC Connection error
    performance_schema=ON" >> /etc/mysql/mysql.conf.d/mysqld.cnf
  10. @craigvantonder craigvantonder revised this gist Mar 16, 2017. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion mysql-connectorj-integration.md
    Original file line number Diff line number Diff line change
    @@ -26,7 +26,7 @@ Create a test script:
    // by adding (say) ?user=craig&password=craig. Not recommended!

    private static final String CONNECTION =
    \"jdbc:mysql://127.0.0.1/mydatabase\";
    \"jdbc:mysql://localhost:3306/mydatabase\";

    public static void main(String[] args) throws
    ClassNotFoundException,SQLException
  11. @craigvantonder craigvantonder revised this gist Mar 16, 2017. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion mysql-connectorj-integration.md
    Original file line number Diff line number Diff line change
    @@ -9,7 +9,7 @@ Install the connector driver - https://help.ubuntu.com/community/JDBCAndMySQL:
    Set classpath globally:

    echo "# Set classpath for JDBC & MySQL
    export CLASSPATH=$CLASSPATH:/usr/share/java/mysql.jar" >> /etc/environment
    CLASSPATH=\".:/usr/share/java/mysql.jar\"" >> /etc/environment

    Create a test script:

  12. @craigvantonder craigvantonder revised this gist Mar 16, 2017. No changes.
  13. @craigvantonder craigvantonder revised this gist Mar 16, 2017. 1 changed file with 31 additions and 19 deletions.
    50 changes: 31 additions & 19 deletions mysql-connectorj-integration.md
    Original file line number Diff line number Diff line change
    @@ -1,9 +1,8 @@

    Install Java SDK and Runtime environment - https://www.digitalocean.com/community/tutorials/how-to-install-java-with-apt-get-on-ubuntu-16-04:

    sudo apt-get install default-jdk

    Install the connector driver - http://www.wottageek.com/2015/07/how-to-set-up-mysqljdbc-on-ubuntu.html:
    Install the connector driver - https://help.ubuntu.com/community/JDBCAndMySQL:

    sudo apt-get install libmysql-java

    @@ -14,33 +13,46 @@ Set classpath globally:

    Create a test script:

    echo "import java.sql.Connection;
    import java.sql.DriverManager;
    echo "import java.sql.*;
    import java.util.Properties;

    public class DBDemo
    {
    // The JDBC Connector Class.
    private static final String dbClassName = \"com.mysql.jdbc.Driver\";

    class JDBCTest {
    // Connection string. mydatabase is the database the program
    // is connecting to. You can include user and password after this
    // by adding (say) ?user=craig&password=craig. Not recommended!

    String url = \"jdbc:mysql://localhost\";
    private static final String CONNECTION =
    \"jdbc:mysql://127.0.0.1/mydatabase\";

    String user = \"username\";
    public static void main(String[] args) throws
    ClassNotFoundException,SQLException
    {
    System.out.println(dbClassName);
    // Class.forName(xxx) loads the jdbc classes and
    // creates a drivermanager class factory
    Class.forName(dbClassName);

    String password = \"password\";
    // Properties for user and password. Here the user and password are both 'craig'
    Properties p = new Properties();
    p.put(\"user\",\"craig\");
    p.put(\"password\",\"craig\");

    public static void main(String args[]) {
    // Now try to connect
    Connection c = DriverManager.getConnection(CONNECTION,p);

    try {
    Connection con;
    con = DriverManager.getConnection(url, user, password);
    System.out.println(\"Success\");
    } catch (Exception e) {
    e.printStackTrace();
    }
    System.out.println(\"It works !\");
    c.close();
    }
    }" > JDBCTest.java
    }" > DBDemo.java

    Compile the test:

    javac JDBCTest.java
    javac DBDemo.java

    Run the test:

    java JDBCTest
    java DBDemo
  14. @craigvantonder craigvantonder revised this gist Mar 16, 2017. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion mysql-connectorj-integration.md
    Original file line number Diff line number Diff line change
    @@ -10,7 +10,7 @@ Install the connector driver - http://www.wottageek.com/2015/07/how-to-set-up-my
    Set classpath globally:

    echo "# Set classpath for JDBC & MySQL
    export CLASSPATH=$CLASSPATH:/usr/share/java/mysql-connector-java.jar" >> /etc/environment
    export CLASSPATH=$CLASSPATH:/usr/share/java/mysql.jar" >> /etc/environment

    Create a test script:

  15. @craigvantonder craigvantonder created this gist Mar 16, 2017.
    46 changes: 46 additions & 0 deletions mysql-connectorj-integration.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,46 @@

    Install Java SDK and Runtime environment - https://www.digitalocean.com/community/tutorials/how-to-install-java-with-apt-get-on-ubuntu-16-04:

    sudo apt-get install default-jdk

    Install the connector driver - http://www.wottageek.com/2015/07/how-to-set-up-mysqljdbc-on-ubuntu.html:

    sudo apt-get install libmysql-java

    Set classpath globally:

    echo "# Set classpath for JDBC & MySQL
    export CLASSPATH=$CLASSPATH:/usr/share/java/mysql-connector-java.jar" >> /etc/environment

    Create a test script:

    echo "import java.sql.Connection;
    import java.sql.DriverManager;

    class JDBCTest {

    String url = \"jdbc:mysql://localhost\";

    String user = \"username\";

    String password = \"password\";

    public static void main(String args[]) {

    try {
    Connection con;
    con = DriverManager.getConnection(url, user, password);
    System.out.println(\"Success\");
    } catch (Exception e) {
    e.printStackTrace();
    }
    }
    }" > JDBCTest.java

    Compile the test:

    javac JDBCTest.java

    Run the test:

    java JDBCTest