---------------------------------------------------------------------------------------- DROP TABLE IF EXISTS `test_post`; CREATE TABLE `test_post` ( `Post_Id` int(10) unsigned NOT NULL AUTO_INCREMENT, `Subject` varchar(50) NOT NULL, `Post_msg` text NOT NULL, PRIMARY KEY (`Post_Id`) ) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8; ---------------------------------------------------------------------------------------- CREATE DEFINER=`root`@`localhost` PROCEDURE `sp_select_test_post`(in id integer) BEGIN SELECT * FROM test_post where post_id=id; END ---------------------------------------------------------------------------------------- import java.sql.*; public class Main { /** * @param args the command line arguments */ public static void main(String[] args) { // TODO code application logic here //System.out.print(); try { Class.forName("com.mysql.jdbc.Driver").newInstance(); Connection conn = DriverManager.getConnection("jdbc:mysql://localhost/void?" + "user=root&password=mother123"); CallableStatement stmt = conn.prepareCall(" call sp_select_test_post(?) "); stmt.setInt(1, 2); stmt.execute(); ResultSet rs = stmt.getResultSet(); /*ResultSetMetaData rmeta = rs.getMetaData(); System.out.print(rmeta.getColumnCount());*/ while(rs.next()) { System.out.print(rs.getString(2) + "\n"); } System.out.print("connected"); conn.close(); } catch (ClassNotFoundException cnfe) { System.out.print(cnfe); } catch(InstantiationException ie) { System.out.print(ie); } catch(IllegalAccessException iae) { System.out.print(iae); } catch(SQLException sqle) { System.out.print(sqle); } } } ---------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------- ----------------------------------------------------------------------------------------