MySQL JDBC Connectivity issues with MemSQL
While testing the connectivity with MySQL JDBC Connector for MemSQL, I’m receiving below errors. My code works fine with MySQL Database but fails with MemSQL Database.
Assuming this might be the issue because MemSQL doesn’t have init_connect global variable. Please go through below illustration which explains the issue more clearly.
java.sql.SQLException: Unknown system variable ‘init_connect’ ( detailed error at below illustration)
[ root @ vm-16af-8253 : /memsql ] tar -zxvf mysql-connector-java-5.1.36.tar.gz
mysql-connector-java-5.1.36/
mysql-connector-java-5.1.36/docs/
mysql-connector-java-5.1.36/src/
mysql-connector-java-5.1.36/src/com/
mysql-connector-java-5.1.36/src/com/mysql/
mysql-connector-java-5.1.36/src/com/mysql/fabric/
mysql-connector-java-5.1.36/src/com/mysql/fabric/hibernate/
mysql-connector-java-5.1.36/src/com/mysql/fabric/jdbc/
———————————————-
mysql-connector-java-5.1.36/src/testsuite/ssl-test-certs/server-key.pem
mysql-connector-java-5.1.36/src/testsuite/ssl-test-certs/server-req.pem
mysql-connector-java-5.1.36/src/testsuite/ssl-test-certs/test-cert-store
[ root @ vm-16af-8253 : /memsql ]
[ root @ vm-16af-8253 : /memsql ]
[ root @ vm-16af-8253 : /memsql ]
[ root @ vm-16af-8253 : /memsql ] ll -lhtr
total 935M
drwxr-xr-x 4 root root 4.0K Jun 19 15:26 mysql-connector-java-5.1.36
drwxr-xr-x 3 attivioid 20 4.0K Jun 29 22:30 memsql-ops-4.0.31
-rw-r–r– 1 root root 149M Jul 30 09:46 memsqlbin_amd64.tar
-rw-r–r– 1 root root 15M Jul 30 09:46 memsql-ops-4.0.31.tar
-rw-r–r– 1 root root 303M Aug 3 02:30 MySQL-5.6.24-1.rhel5.x86_64.rpm-bundle.tar
-rw-r–r– 1 root root 115K Aug 3 03:25 mysql-connector-odbc-5.1.5r1144-7.el6.x86_64.rpm
-rw-r–r– 1 root root 2.4M Aug 3 03:31 mysql-connector-odbc-5.3.4-1.el6.x86_64.rpm
-rw-r–r– 1 root root 301K Aug 3 03:34 lib64unixODBC2-2.3.2-4.mga5.x86_64.rpm
-rw-r–r– 1 root root 1.4M Aug 3 03:37 glibc-2.14.1-14.12.5.x86_64.rpm
-rw-r–r– 1 root root 4.4M Aug 3 03:42 glibc-2.12-1.149.el6_6.5.i686.rpm
-rw-r–r– 1 root root 457M Aug 3 05:20 memsql_install_packages.tar.gz
-rw-r–r– 1 root root 2.2K Sep 1 05:14 memory_alerts.sh
-rw-r–r– 1 root root 3.8M Sep 1 06:49 mysql-connector-java-5.1.36.tar.gz
[ root @ vm-16af-8253 : /memsql ]
[ root @ vm-16af-8253 : /memsql ] cd mysql-connector-java-5.1.36
[ root @ vm-16af-8253 : /memsql/mysql-connector-java-5.1.36 ]
[ root @ vm-16af-8253 : /memsql/mysql-connector-java-5.1.36 ]
[ root @ vm-16af-8253 : /memsql/mysql-connector-java-5.1.36 ]
[ root @ vm-16af-8253 : /memsql/mysql-connector-java-5.1.36 ] ll -lhrt
total 1.4M
-rw-r–r– 1 root root 18K Jun 19 15:26 COPYING
-rw-r–r– 1 root root 230K Jun 19 15:26 CHANGES
-rw-r–r– 1 root root 89K Jun 19 15:26 build.xml
drwxr-xr-x 8 root root 4.0K Jun 19 15:26 src
-rw-r–r– 1 root root 63K Jun 19 15:26 README.txt
-rw-r–r– 1 root root 60K Jun 19 15:26 README
-rw-r–r– 1 root root 950K Jun 19 15:26 mysql-connector-java-5.1.36-bin.jar
drwxr-xr-x 2 root root 4.0K Sep 1 06:49 docs
[ root @ vm-16af-8253 : /memsql/mysql-connector-java-5.1.36 ]
[ root @ vm-16af-8253 : /memsql/mysql-connector-java-5.1.36 ] mysql -u root -h vm-16af-8253 -P 3306 –prompt=”memsql> “
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MySQL connection id is 10
Server version: 5.5.8 MemSQL source distribution (compatible; MySQL Enterprise & MySQL Commercial)
Copyright (c) 2000, 2015, Oracle, MariaDB Corporation Ab and others.
Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.
memsql>
memsql>
memsql>
memsql>
memsql>
memsql> grant all privileges on *.* to myusr IDENTIFIED BY ‘mypwd’ WITH GRANT OPTION;
Query OK, 0 rows affected (0.25 sec)
memsql>
memsql> show grants for ‘myusr’@’%’;
+———————————————————————————————————————————+
| Grants for myusr@% |
+———————————————————————————————————————————+
| GRANT ALL PRIVILEGES ON *.* TO ‘myusr’@’%’ IDENTIFIED BY PASSWORD ‘*6F1F0C7FA57187E0D959C29F4BC7F826ED5A9169’ WITH GRANT OPTION |
+———————————————————————————————————————————+
1 row in set (0.00 sec)
memsql>
memsql>
memsql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
memsql> create database jdbc_db;
Query OK, 1 row affected (0.82 sec)
memsql> use jdbc_db
Database changed
memsql>
memsql>
memsql> create table mytbl (id int, name varchar(20));
ERROR 1751 (HY000): Distributed tables must either have a PRIMARY or SHARD key. Visit http://docs.memsql.com/4.0/concepts/porting-apps/ for more information
memsql>
memsql>
memsql> create table mytbl (id int, name varchar(20), primary key(id));
Query OK, 0 rows affected (10.46 sec)
memsql> insert into mytbl (id,name) values (1,’jdbc driver test’);
Query OK, 1 row affected (1.49 sec)
memsql> insert into mytbl (id,name) values (2,’jdbc driver success’);
Query OK, 1 row affected (0.00 sec)
memsql> insert into mytbl (id,name) values (3,’jdbc connectivity’);
Query OK, 1 row affected (0.00 sec)
memsql>
memsql>
memsql> select * from mytbl;
+—-+———————+
| id | name |
+—-+———————+
| 1 | jdbc driver test |
| 3 | jdbc connectivity |
| 2 | jdbc driver success |
+—-+———————+
3 rows in set (2.87 sec)
memsql> exit
[ root @ vm-16af-8253 : /memsql/mysql-connector-java-5.1.36 ] cp /tmp/jdk-8u5-linux-x64.gz .
[ root @ vm-16af-8253 : /memsql/mysql-connector-java-5.1.36 ] ll -lhtr
total 154M
-rw-r–r– 1 root root 18K Jun 19 15:26 COPYING
-rw-r–r– 1 root root 230K Jun 19 15:26 CHANGES
-rw-r–r– 1 root root 89K Jun 19 15:26 build.xml
drwxr-xr-x 8 root root 4.0K Jun 19 15:26 src
-rw-r–r– 1 root root 63K Jun 19 15:26 README.txt
-rw-r–r– 1 root root 60K Jun 19 15:26 README
-rw-r–r– 1 root root 950K Jun 19 15:26 mysql-connector-java-5.1.36-bin.jar
drwxr-xr-x 2 root root 4.0K Sep 1 06:49 docs
-rw-r–r– 1 root root 1.4K Sep 1 07:00 DBDemo.java
-rw-r–r– 1 root root 152M Sep 1 07:05 jdk-8u5-linux-x64.gz
[ root @ vm-16af-8253 : /memsql/mysql-connector-java-5.1.36 ]
[ root @ vm-16af-8253 : /memsql/mysql-connector-java-5.1.36 ]
[ root @ vm-16af-8253 : /memsql/mysql-connector-java-5.1.36 ]
[ root @ vm-16af-8253 : /memsql/mysql-connector-java-5.1.36 ]
[ root @ vm-16af-8253 : /memsql/mysql-connector-java-5.1.36 ]
[ root @ vm-16af-8253 : /memsql/mysql-connector-java-5.1.36 ]
[ root @ vm-16af-8253 : /memsql/mysql-connector-java-5.1.36 ] tar -zxvf jdk-8u5-linux-x64.gz
jdk1.8.0_05/
jdk1.8.0_05/javafx-src.zip
jdk1.8.0_05/bin/
jdk1.8.0_05/bin/jmc
jdk1.8.0_05/bin/serialver
jdk1.8.0_05/bin/jmc.ini
jdk1.8.0_05/bin/jstack
jdk1.8.0_05/bin/rmiregi
dk1.8.0_05/jre/COPYRIGHT
jdk1.8.0_05/jre/THIRDPARTYLICENSEREADME-JAVAFX.txt
jdk1.8.0_05/jre/Welcome.html
jdk1.8.0_05/jre/README
jdk1.8.0_05/README.html
[ root @ vm-16af-8253 : /memsql/mysql-connector-java-5.1.36 ]
[ root @ vm-16af-8253 : /memsql/mysql-connector-java-5.1.36 ]
[ root @ vm-16af-8253 : /memsql/mysql-connector-java-5.1.36 ]
[ root @ vm-16af-8253 : /memsql/mysql-connector-java-5.1.36 ]
[ root @ vm-16af-8253 : /memsql/mysql-connector-java-5.1.36 ] ll -lhtr
total 154M
drwxr-xr-x 8 uucp 143 4.0K Mar 18 2014 jdk1.8.0_05
-rw-r–r– 1 root root 18K Jun 19 15:26 COPYING
-rw-r–r– 1 root root 230K Jun 19 15:26 CHANGES
-rw-r–r– 1 root root 89K Jun 19 15:26 build.xml
drwxr-xr-x 8 root root 4.0K Jun 19 15:26 src
-rw-r–r– 1 root root 63K Jun 19 15:26 README.txt
-rw-r–r– 1 root root 60K Jun 19 15:26 README
-rw-r–r– 1 root root 950K Jun 19 15:26 mysql-connector-java-5.1.36-bin.jar
drwxr-xr-x 2 root root 4.0K Sep 1 06:49 docs
-rw-r–r– 1 root root 1.4K Sep 1 07:00 DBDemo.java
-rw-r–r– 1 root root 152M Sep 1 07:05 jdk-8u5-linux-x64.gz
[ root @ vm-16af-8253 : /memsql/mysql-connector-java-5.1.36 ]
[ root @ vm-16af-8253 : /memsql/mysql-connector-java-5.1.36 ]
[ root @ vm-16af-8253 : /memsql/mysql-connector-java-5.1.36 ] cd jdk1.8.0_05/
[ root @ vm-16af-8253 : /memsql/mysql-connector-java-5.1.36/jdk1.8.0_05 ]
[ root @ vm-16af-8253 : /memsql/mysql-connector-java-5.1.36/jdk1.8.0_05 ]
[ root @ vm-16af-8253 : /memsql/mysql-connector-java-5.1.36/jdk1.8.0_05 ] pwd
/memsql/mysql-connector-java-5.1.36/jdk1.8.0_05
[ root @ vm-16af-8253 : /memsql/mysql-connector-java-5.1.36/jdk1.8.0_05 ]
[ root @ vm-16af-8253 : /memsql/mysql-connector-java-5.1.36/jdk1.8.0_05 ]
[ root @ vm-16af-8253 : /memsql/mysql-connector-java-5.1.36/jdk1.8.0_05 ]
[ root @ vm-16af-8253 : /memsql/mysql-connector-java-5.1.36/jdk1.8.0_05 ] ll -lhrt
total 25M
-rw-r–r– 1 uucp 143 121K Mar 17 2014 THIRDPARTYLICENSEREADME-JAVAFX.txt
-rw-r–r– 1 uucp 143 4.5M Mar 17 2014 javafx-src.zip
-r–r–r– 1 uucp 143 175K Mar 18 2014 THIRDPARTYLICENSEREADME.txt
-rw-r–r– 1 uucp 143 21M Mar 18 2014 src.zip
-rw-r–r– 1 uucp 143 525 Mar 18 2014 release
-r–r–r– 1 uucp 143 159 Mar 18 2014 README.html
drwxr-xr-x 4 uucp 143 4.0K Mar 18 2014 man
-r–r–r– 1 uucp 143 40 Mar 18 2014 LICENSE
drwxr-xr-x 3 uucp 143 4.0K Mar 18 2014 include
drwxr-xr-x 4 uucp 143 4.0K Mar 18 2014 db
-r–r–r– 1 uucp 143 3.2K Mar 18 2014 COPYRIGHT
drwxr-xr-x 5 uucp 143 4.0K Mar 18 2014 jre
drwxr-xr-x 2 uucp 143 4.0K Mar 18 2014 bin
drwxr-xr-x 5 uucp 143 4.0K Mar 18 2014 lib
[ root @ vm-16af-8253 : /memsql/mysql-connector-java-5.1.36/jdk1.8.0_05 ]
[ root @ vm-16af-8253 : /memsql/mysql-connector-java-5.1.36/jdk1.8.0_05 ] which java
/usr/bin/which: no java in (/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin:/usr/local/mysql/bin/:/usr/local/mysql/bin/:/root/bin)
[ root @ vm-16af-8253 : /memsql/mysql-connector-java-5.1.36/jdk1.8.0_05 ]
[ root @ vm-16af-8253 : /memsql/mysql-connector-java-5.1.36/jdk1.8.0_05 ]
[ root @ vm-16af-8253 : /memsql/mysql-connector-java-5.1.36 ]
[ root @ vm-16af-8253 : /memsql/mysql-connector-java-5.1.36 ] echo “export CLASSPATH=/memsql/mysql-connector-java-5.1.36/mysql-connector-java-5.1.35-bin.jar” >> ~/.bashrc
[ root @ vm-16af-8253 : /memsql/mysql-connector-java-5.1.36 ] echo “export JAVA_HOME=/memsql/mysql-connector-java-5.1.36/jdk1.8.0_05” >> ~/.bashrc
[ root @ vm-16af-8253 : /memsql/mysql-connector-java-5.1.36 ] source ~/.bashrc
[ root @ vm-16af-8253 : /memsql/mysql-connector-java-5.1.36 ]
[ root @ vm-16af-8253 : /memsql/mysql-connector-java-5.1.36 ] echo “export PATH=$PATH:$JAVA_HOME/bin” >> ~/.bashrc
[ root @ vm-16af-8253 : ~ ] which java
/memsql/mysql-connector-java-5.1.36/jdk1.8.0_05/bin/java
[ root @ vm-16af-8253 : ~ ]
[ root @ vm-16af-8253 : /memsql/mysql-connector-java-5.1.36 ] javac DBDemo.java
[ root @ vm-16af-8253 : /memsql/mysql-connector-java-5.1.36 ]
[ root @ vm-16af-8253 : /memsql/mysql-connector-java-5.1.36 ]
[ root @ vm-16af-8253 : /memsql/mysql-connector-java-5.1.36 ]
[ root @ vm-16af-8253 : /memsql/mysql-connector-java-5.1.36 ] ll -lhtr
total 154M
drwxr-xr-x 8 uucp 143 4.0K Mar 18 2014 jdk1.8.0_05
-rw-r–r– 1 root root 18K Jun 19 15:26 COPYING
-rw-r–r– 1 root root 230K Jun 19 15:26 CHANGES
-rw-r–r– 1 root root 89K Jun 19 15:26 build.xml
drwxr-xr-x 8 root root 4.0K Jun 19 15:26 src
-rw-r–r– 1 root root 63K Jun 19 15:26 README.txt
-rw-r–r– 1 root root 60K Jun 19 15:26 README
-rw-r–r– 1 root root 950K Jun 19 15:26 mysql-connector-java-5.1.36-bin.jar
drwxr-xr-x 2 root root 4.0K Sep 1 06:49 docs
-rw-r–r– 1 root root 1.4K Sep 1 07:00 DBDemo.java
-rw-r–r– 1 root root 152M Sep 1 07:05 jdk-8u5-linux-x64.gz
-rw-r–r– 1 root root 2.8K Sep 1 07:22 DBDemo.class
[ root @ vm-16af-8253 : /memsql/mysql-connector-java-5.1.36 ]
[ root @ vm-ecce-c4d1 : /var/lib/mysql/mysql-connector-java-5.1.36 ] cat DBDemo.java
import java.sql.*;
import java.util.Properties;
public class DBDemo
{
private static final String dbClassName = “com.mysql.jdbc.Driver”;
private static final String CONNECTION =
“jdbc:mysql://vm-ecce-c4d1/jdbc_db”;
public static void main(String[] args) throws
ClassNotFoundException,SQLException
{
System.out.println(dbClassName);
Class.forName(dbClassName);
Properties p = new Properties();
p.put(“user”,”myusr”);
p.put(“password”,”mypwd”);
Connection c = DriverManager.getConnection(CONNECTION,p);
System.out.println(“It works !”);
// code for MySQL database connectivity
String url = “jdbc:mysql://vm-ecce-c4d1:3306/jdbc_db”;
String username = “myusr”;
String password = “mypwd”;
System.out.println(“Connecting database…”);
try (Connection connection = DriverManager.getConnection(url, username, password)) {
System.out.println(“Database connected!”);
} catch (SQLException e) {
throw new IllegalStateException(“Cannot connect the database!”, e);
}
Connection conn = DriverManager.getConnection
(“jdbc:mysql://vm-ecce-c4d1:3306/jdbc_db”, “myusr”, “mypwd”);
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery(“SELECT id,name FROM mytbl”);
System.out.printf(“%n”);
System.out.println(“id name”);
while (rs.next()) {
int x = rs.getInt(“id”);
String s = rs.getString(“name”);
System.out.println(x + ” ” + s);
}
stmt.close();
// code for MemSQL database connectivity
Connection connection = null;
try {
connection = DriverManager.getConnection(“jdbc:mysql://vm-16af-8253:3306”, “myusr”, “mypwd”);
Statement stmt1 = connection.createStatement();
stmt1.execute(“DROP DATABASE IF EXISTS jdbc_db”);
stmt1.execute(“CREATE DATABASE jdbc_db”);
stmt1.execute(“use jdbc_db”);
stmt1.execute(“CREATE TABLE tbl(id INT PRIMARY KEY AUTO_INCREMENT, name VARCHAR(50) NOT NULL)”);
stmt1.execute(“INSERT INTO tbl (name) VALUES (‘My First Insert with JDBC Connector’), (‘You are successful with connection’)”);
ResultSet rs1 = stmt.executeQuery(“SELECT * FROM tbl”);
while (rs1.next())
{
System.out.println(“((‘” + rs1.getInt(“id”) + “‘, ‘” + rs1.getString(“name”) + “‘),)”);
}
} catch (SQLException e) {
System.out.println(“Failed to make JDBC Connection with your MemSQL!”);
e.printStackTrace();
return;
}
conn.close();
c.close();
}
}
[ root @ vm-ecce-c4d1 : /var/lib/mysql/mysql-connector-java-5.1.36 ]
[ root @ vm-ecce-c4d1 : /var/lib/mysql/mysql-connector-java-5.1.36 ]
[ root @ vm-ecce-c4d1 : /var/lib/mysql/mysql-connector-java-5.1.36 ] java -cp .:/var/lib/mysql/mysql-connector-java-5.1.36/mysql-connector-java-5.1.36-bin.jar DBDemo
com.mysql.jdbc.Driver
It works !
Connecting database…
Database connected!
id name
1 jdbc driver test
2 jdbc driver success
3 jdbc connectivity
Failed to make JDBC Connection with your MemSQL!
java.sql.SQLException: Unknown system variable ‘init_connect’
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:998)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3847)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3783)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2447)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2594)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2541)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2499)
at com.mysql.jdbc.StatementImpl.executeQuery(StatementImpl.java:1432)
at com.mysql.jdbc.ConnectionImpl.loadServerVariables(ConnectionImpl.java:3870)
at com.mysql.jdbc.ConnectionImpl.initializePropsFromServer(ConnectionImpl.java:3284)
at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2293)
at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2079)
at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:794)
at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:44)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:408)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:400)
at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:399)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:325)
at java.sql.DriverManager.getConnection(DriverManager.java:664)
at java.sql.DriverManager.getConnection(DriverManager.java:247)
at DBDemo.main(DBDemo.java:58)
[ root @ vm-ecce-c4d1 : /var/lib/mysql/mysql-connector-java-5.1.36 ]
[ root @ vm-ecce-c4d1 : /var/lib/mysql/mysql-connector-java-5.1.36 ]
[ root @ vm-ecce-c4d1 : /var/lib/mysql/mysql-connector-java-5.1.36 ]
[ root @ vm-ecce-c4d1 : /var/lib/mysql/mysql-connector-java-5.1.36 ]
[ root @ vm-ecce-c4d1 : /var/lib/mysql/mysql-connector-java-5.1.36 ] mysql -h vm-16af-8253 -u “myusr” -p”mypwd” -P 3306 –prompt=”memsql> “
Warning: Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 58
Server version: 5.5.8 MemSQL source distribution (compatible; MySQL Enterprise & MySQL Commercial)
Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.
memsql>
memsql>
memsql> show global variables like “%init%”;
Empty set (0.00 sec)
memsql>
memsql>
memsql> ^DBye
[ root @ vm-ecce-c4d1 : /var/lib/mysql/mysql-connector-java-5.1.36 ] mysql -h vm-ecce-c4d1 -u “myusr” -p”mypwd” -P 3306
Warning: Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 84
Server version: 5.6.25-log MySQL Community Server (GPL)
Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.
mysql> show global variables like “%init%”;
+————————+——-+
| Variable_name | Value |
+————————+——-+
| init_connect | |
| init_file | |
| init_slave | |
| table_definition_cache | 1400 |
+————————+——-+
4 rows in set (0.00 sec)
mysql>
mysql>
mysql>
==============================================================================================================
All memsql-ops 4.x.x versions are compatible with any memsql 4.x.x.
The only compatibility issue was with the JDBC driver:
Memsql 4.0.2 and earlier requires JDBC 5.0.8
Memsql 4.0.3 and later supports JDBC 5.0.8 and later
This is a known issue with memsql versions < 4.0.3. See release note here: http://docs.memsql.com/latest/release_notes/4.0releasenotes/#version-4-0-3
You can use the previous GA release of the JDBC driver, version 5.0.8. Here is the download link: https://dev.mysql.com/downloads/file.php?id=13597
4.0.35 is the ops version. The engine version is currently 4.0.4. If you use memsql engine version > 4.0.3, you can use the JDBC version that you are currently testing.
==============================================================================================================
[ root @ vm-16af-8253 : /memsql ] cp /tmp/mysql-connector-java-5.0.8.tar.gz .
[ root @ vm-16af-8253 : /memsql ]
[ root @ vm-16af-8253 : /memsql ]
[ root @ vm-16af-8253 : /memsql ] ll -lhtr
total 943M
drwxr-xr-x 3 attivioid 20 4.0K Jun 29 22:30 memsql-ops-4.0.31
-rw-r–r– 1 root root 149M Jul 30 09:46 memsqlbin_amd64.tar
-rw-r–r– 1 root root 15M Jul 30 09:46 memsql-ops-4.0.31.tar
-rw-r–r– 1 root root 303M Aug 3 02:30 MySQL-5.6.24-1.rhel5.x86_64.rpm-bundle.tar
-rw-r–r– 1 root root 115K Aug 3 03:25 mysql-connector-odbc-5.1.5r1144-7.el6.x86_64.rpm
-rw-r–r– 1 root root 301K Aug 3 03:34 lib64unixODBC2-2.3.2-4.mga5.x86_64.rpm
-rw-r–r– 1 root root 1.4M Aug 3 03:37 glibc-2.14.1-14.12.5.x86_64.rpm
-rw-r–r– 1 root root 4.4M Aug 3 03:42 glibc-2.12-1.149.el6_6.5.i686.rpm
-rw-r–r– 1 root root 457M Aug 3 05:20 memsql_install_packages.tar.gz
-rw-r–r– 1 root root 2.2K Sep 1 05:14 memory_alerts.sh
-rw-r–r– 1 root root 3.8M Sep 1 06:49 mysql-connector-java-5.1.36.tar.gz
drwxr-xr-x 5 root root 4.0K Sep 1 09:33 mysql-connector-java-5.1.36
-rw-r–r– 1 root root 2.4M Sep 1 10:58 mysql-connector-odbc-5.3.4-1.el6.x86_64.rpm
-rw-r–r– 1 root root 8.3M Sep 2 03:36 mysql-connector-java-5.0.8.tar.gz
[ root @ vm-16af-8253 : /memsql ]
[ root @ vm-16af-8253 : /memsql ]
[ root @ vm-16af-8253 : /memsql ] tar -zxvf mysql-connector-java-5.0.8.tar.gz
mysql-connector-java-5.0.8/
mysql-connector-java-5.0.8/debug/
mysql-connector-java-5.0.8/docs/
mysql-connector-java-5.0.8/src/
mysql-connector-java-5.0.8/src/com/
mysql-connector-java-5.0.8/src/com/mysql/
mysql-connector-java-5.0.8/src/com/mysql/jdbc/
=—————————–
mysql-connector-java-5.0.8/src/testsuite/ssl-test-certs/server-key.pem
mysql-connector-java-5.0.8/src/testsuite/ssl-test-certs/server-req.pem
mysql-connector-java-5.0.8/src/testsuite/ssl-test-certs/test-cert-store
[ root @ vm-16af-8253 : /memsql ]
[ root @ vm-16af-8253 : /memsql ] cd mysql-connector-java-5.0.8
[ root @ vm-16af-8253 : /memsql/mysql-connector-java-5.0.8 ]
[ root @ vm-16af-8253 : /memsql/mysql-connector-java-5.0.8 ]
[ root @ vm-16af-8253 : /memsql/mysql-connector-java-5.0.8 ]
[ root @ vm-16af-8253 : /memsql/mysql-connector-java-5.0.8 ]
[ root @ vm-16af-8253 : /memsql/mysql-connector-java-5.0.8 ] ll -lhrt
total 768K
drwxr-xr-x 7 root root 4.0K Oct 4 2007 src
-rw-r–r– 1 root root 5.2K Oct 4 2007 EXCEPTIONS-CONNECTOR-J
-rw-r–r– 1 root root 19K Oct 4 2007 COPYING
-rw-r–r– 1 root root 145K Oct 4 2007 CHANGES
-rw-r–r– 1 root root 38K Oct 4 2007 build.xml
-rw-r–r– 1 root root 1.4K Oct 4 2007 README.txt
-rw-r–r– 1 root root 1.3K Oct 4 2007 README
-rw-r–r– 1 root root 529K Oct 4 2007 mysql-connector-java-5.0.8-bin.jar
drwxr-xr-x 2 root root 4.0K Sep 2 03:36 debug
drwxr-xr-x 2 root root 4.0K Sep 2 03:36 docs
[ root @ vm-16af-8253 : /memsql/mysql-connector-java-5.0.8 ]
[ root @ vm-16af-8253 : /memsql/mysql-connector-java-5.0.8 ] cat DBDemo.java
import java.sql.*;
import java.util.Properties;
public class DBDemo
{
private static final String dbClassName = “com.mysql.jdbc.Driver”;
private static final String CONNECTION = “jdbc:mysql://vm-16af-8253/memsql”;
public static void main(String[] args) throws
ClassNotFoundException,SQLException
{
System.out.println(dbClassName);
Class.forName(dbClassName);
Properties p = new Properties();
p.put(“user”,”myusr”);
p.put(“password”,”mypwd”);
Connection c = DriverManager.getConnection(CONNECTION,p);
System.out.println(“It works !”);
String url = “jdbc:mysql://vm-16af-8253:3306/memsql”;
String username = “myusr”;
String password = “mypwd”;
System.out.println(“Connecting to database …”);
try (Connection connection = DriverManager.getConnection(url, username, password)) {
System.out.println(“Database connected!”);
} catch (SQLException e) {
throw new IllegalStateException(“Cannot connect the database!”, e);
}
Connection connection = null;
try {
connection = DriverManager.getConnection(“jdbc:mysql://vm-16af-8253:3306”, “myusr”, “mypwd”);
Statement stmt = connection.createStatement();
stmt.execute(“DROP DATABASE IF EXISTS jdbc_db”);
stmt.execute(“CREATE DATABASE jdbc_db”);
stmt.execute(“use jdbc_db”);
stmt.execute(“CREATE TABLE tbl(id INT PRIMARY KEY AUTO_INCREMENT, name VARCHAR(50) NOT NULL)”);
stmt.execute(“INSERT INTO tbl (name) VALUES (‘My First Insert with JDBC Connector’), (‘You are successful with connection’)”);
ResultSet rs1 = stmt.executeQuery(“SELECT * FROM tbl”);
while (rs1.next())
{
System.out.println(“((‘” + rs1.getInt(“id”) + “‘, ‘” + rs1.getString(“name”) + “‘),)”);
}
} catch (SQLException e) {
System.out.println(“Failed to make JDBC Connection with your MemSQL!”);
e.printStackTrace();
return;
}
connection.close();
c.close();
}
}
[ root @ vm-16af-8253 : /memsql/mysql-connector-java-5.0.8 ]
[ root @ vm-16af-8253 : /memsql/mysql-connector-java-5.0.8 ] javac DBDemo.java
[ root @ vm-16af-8253 : /memsql/mysql-connector-java-5.0.8 ]
[ root @ vm-16af-8253 : /memsql/mysql-connector-java-5.0.8 ]
[ root @ vm-16af-8253 : /memsql/mysql-connector-java-5.0.8 ]
[ root @ vm-16af-8253 : /memsql/mysql-connector-java-5.0.8 ] java -cp .:/memsql/mysql-connector-java-5.0.8/mysql-connector-java-5.0.8-bin.jar DBDemo
com.mysql.jdbc.Driver
It works !
Connecting to database …
Database connected!
((‘1’, ‘My First Insert with JDBC Connector’),)
((‘2’, ‘You are successful with connection’),)
[ root @ vm-16af-8253 : /memsql/mysql-connector-java-5.0.8 ]
Thanks for reporting this. Support for newer mysql JDBC drivers was added in MemSQL 4.0.3 (see the release notes section here: http://docs.memsql.com/latest/release_notes/4.0releasenotes/)
-Adam
MemSQL Engineering