I am using Jethon 2.2.1 and MySQL Connector / J 5.1 to access a MySQL database. I want to use zxJDBC's cursor. Tables () method to recover the list of tables in that database. However, this method does not always do any .
According to the zxJDBC documentation, cursor. Tibles () is the same as the database of Java's Metaata.getTables (). When I call the Java method from Jethon, it works as expected, but the use of the zxJDBC package does not work for me. Here's what I have tried:
import java .sql *; Public class table test {public static zero table (string url) {try {class.forName ("com.mysql.jdbc.Driver"); Connection conn = DriverManager.getConnection (url, "root", null); Database Metadata Meta = conn.getMetaData (); Results set rs = meta.gettables (empty, zero, "%", new string [] {"table"}); While (rsnext ()) {System.out.println (rs.getString ("TABLE_NAME")); }} Hold (exception e) {e.printStackTrace (); }}}
When I tell it to Jethon, it's all right. Importing zxJDBC from Com.ziclix.python.sql import TableTest url = 'Jdbc: mysql: // localhost / jythontest' print 'Java:' TableTest.tables (url); Print 'Python:' conn = zxJDBC.connect (URL, 'root', none, 'com.mysql.jdbc.Driver') cursor = conn.cursor () print cursor.tables (none, none, '% In my test database, there are two tables named 'table_a' and 'table_b'. The output is:
java ('table',) : Table_a table_b Python: None
I have tried it with the same result on Linux and Maccode.
Thank you.
Thank you.
Print
Import zxJDBC import tableTest url = 'jdbc: mysql: // localhost / jythontest' from com.ziclix.python.sql Import Java: 'TableTest.tables (url); Print 'Python:' conn = zxJDBC.connect (URL, 'root', none, 'com.mysql.jdbc.Driver') cursor = conn.cursor () print cursor.tables (none, none, '% ', ( I agree:
Comments
Post a Comment