import java.sql.*;
//import com.mysql.jdbc.*;
/**
* <p>Title: </p>
*
* <p>Description: </p>
*
* <p>Copyright: Copyright (c) 2008</p>
*
* <p>Company: </p>
*
* @author Marco Tusa
* @version 1.0
*/
public class test1 {
public test1() {
}
public static void main(String[] args) {
try {
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection myConnection = DriverManager.getConnection(
"jdbc:mysql://138.132.167.150:3306/world1?user=grp1&password=grp1");
Statement stmt1 = myConnection.createStatement();
stmt1.executeUpdate("use world1");
CallableStatement cs = myConnection.prepareCall(
"{CALL UNBOUND_DEMO(?)}");
cs.setString(1, "Lombardia");
boolean moreResultSets = cs.execute();
while (moreResultSets) {
ResultSet rs = cs.getResultSet();
ResultSetMetaData rsmd = rs.getMetaData();
StringBuffer buffer = new StringBuffer();
for (int i = 1; i <= rsmd.getColumnCount(); i++)
buffer.append(rsmd.getColumnName(i)).append("\t");
System.out.println(buffer.toString());
while (rs.next()) {
buffer.setLength(0);
for (int i = 1; i <= rsmd.getColumnCount(); i++)
buffer.append(rs.getString(i)).append("\t");
System.out.println(buffer.toString());
}
moreResultSets = cs.getMoreResults();
}
} catch (Exception ex) {
ex.printStackTrace();
}
}
}