NYWC database through JDBC
import java.sql.*;
public class BiosToTab {
public static void main(String[] args) {
String userName = "elharo";
String password = args[0];
String host = "luna.oit.unc.edu";
try {
//Requires JDBC MySQL Driver from http://www.worldserver.com/mm.mysql/
Class.forName("org.gjt.mm.mysql.Driver").newInstance();
// Connect to the database
Connection connection = DriverManager.getConnection(
"jdbc:mysql://" + host + "/NYWC", userName, password);
Statement statement = connection.createStatement();
ResultSet bios = statement.executeQuery(
"SELECT * FROM composers ORDER BY ComposerLastName, ComposerFirstName");
while (bios.next()) {
/* primary key */
String lastName = bios.getString("ComposerLastName");
String middleName = bios.getString("ComposerMiddleName");
String firstName = bios.getString("ComposerFirstName");
/* These can be null */
String bio = bios.getString("ComposerBio");
String email = bios.getString("ComposerEmail");
String url = bios.getString("ComposerURL");
String title = bios.getString("ComposerTitle");
String voice = bios.getString("ComposerVoice");
String fax = bios.getString("ComposerFax");
String street = bios.getString("ComposerStreet");
String suite = bios.getString("ComposerSuite");
String state = bios.getString("ComposerState");
String city = bios.getString("ComposerCity");
String country = bios.getString("ComposerCountry");
String zip = bios.getString("ComposerZip");
Date expires = bios.getDate ("ComposerMembershipExpires");
System.out.println(firstName + " " + lastName);
System.out.flush();
}
}
catch (Exception e) {
System.err.println("Unable to load driver.");
e.printStackTrace();
}
}
}
View result in Browser