38 lines
1.4 KiB
Java
38 lines
1.4 KiB
Java
// 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();
|
|
}
|
|
}
|