===[[Java]]===
<pre>
package info.typea.songdict.sample;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
public class DbAccess {
public void doWork() {
try (Connection conn = DriverManager.getConnection(
"jdbc:mysql://hostname/dbname",
"username",
"password")) {
Statement stmt = conn.createStatement();
ResultSet resultSet
= stmt.executeQuery("select substr(reading,1,2) from song_element group by substr(reading,1,2)");
while (resultSet.next()) {
System.out.println(resultSet.getString(1));
}
} catch(Exception e) {
System.out.println(String.format("ERROR : %s", e));
}
}
}
</pre>
==[[Tips]]==
===管理===