Import tests
This commit is contained in:
parent
02403268cc
commit
7e9050edf5
9 changed files with 375 additions and 1 deletions
38
connector-example/Test.java
Normal file
38
connector-example/Test.java
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
// https://fedoraproject.org/wiki/MariaDB_JDBC_connector
|
||||
import java.sql.*;
|
||||
|
||||
public class Test {
|
||||
public static void main(String[] args) throws Exception {
|
||||
// create our mysql database connection
|
||||
String host = "localhost";
|
||||
String dbname = "information_schema";
|
||||
String url = "jdbc:mariadb://" + host + "/" + dbname;
|
||||
String username = "root";
|
||||
String password = "";
|
||||
Connection conn = DriverManager.getConnection(url, username, password);
|
||||
|
||||
// our SQL SELECT query.
|
||||
// if you only need a few columns, specify them by name instead of using "*"
|
||||
String query = "SELECT * FROM ENGINES";
|
||||
|
||||
// create the java statement
|
||||
Statement st = conn.createStatement();
|
||||
|
||||
// execute the query, and get a java resultset
|
||||
ResultSet rs = st.executeQuery(query);
|
||||
|
||||
// iterate through the java resultset
|
||||
while (rs.next()) {
|
||||
String engine = rs.getString("ENGINE");
|
||||
String support = rs.getString("SUPPORT");
|
||||
String comment = rs.getString("COMMENT");
|
||||
String transactions = rs.getString("TRANSACTIONS");
|
||||
String xa = rs.getString("XA");
|
||||
String savepoints = rs.getString("SAVEPOINTS");
|
||||
|
||||
// print the results
|
||||
System.out.format("%s, %s, %s, %s, %s, %s\n", engine, support, comment, transactions, xa, savepoints);
|
||||
}
|
||||
st.close();
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue