import java.io.*; import java.sql.*; public class JDBCPreparedStatement { public static void main ( String args[]){ try{ Class.forName("com.mysql.jdbc.Driver"); Connection c = DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root", "root"); PreparedStatement stmt = c.prepareStatement("select * from tableName"); ResultSet rs = stmt.executeQuery(); while(rs.next()){ System.out.println(rs.getInt(1) + " (" + rs.getString(2) + ")"); } } catch(SQLException e){ System.err.println(e); } } }
|
Thanx for JDBC Prepared Statement Example
ReplyDelete