1-) Java -
MySQL ile bağlanmak ve select yapıp ekrana yazmak(online internet)
public Connection GetConnection() {
Connection con;
con = null;
try {
Class.forName("com.mysql.jdbc.Driver");
String database = "jdbc:mysql://94.73.146.229/dbFE862744B8";//java_mysq veri tabanının ismidir
con = (Connection) DriverManager.getConnection(database, "userFE862744B8", "OEaq38L3");
} catch (ClassNotFoundException | SQLException e) {
JOptionPane.showMessageDialog(null, e.toString(), "student DataBase", JOptionPane.INFORMATION_MESSAGE);
}
return con;
}
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
try {
try (Connection conn = GetConnection()) {
String sql = "INSERT INTO ramazan (isim,soyisim) values (?,?)";
PreparedStatement statement = conn.prepareStatement(sql);
statement.setString(1, "ramazan1");
statement.setString(2, "haber1");
int row = statement.executeUpdate();
if (row > 0) {
System.out.println("A contact was inserted with photo image.");
}
conn.close();
}
} catch (SQLException ex) {
System.out.println("hata buradadır " + ex.getMessage());
}
}