import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
public class Main {
public static void main(String[] argv) throws Exception {
Connection con = null;
Class.forName("com.mysql.jdbc.Driver");
con = DriverManager.getConnection("jdbc:mysql://localhost:3306/jdbctutorial", "root", "root");
String sql = "INSERT datatypes VALUES(?,?,?)";
PreparedStatement prest = con.prepareStatement(sql);
prest.setByte(1, (byte) 5);
prest.setShort(2, (short) 65);
prest.setLong(3, (long) 254);
int row = prest.executeUpdate();
System.out.println(row + " row(s) affected)");
}
}
|