Skip to content

Instantly share code, notes, and snippets.

@austa
Created June 17, 2014 14:59
Show Gist options
  • Save austa/06c887d308f098d7e1be to your computer and use it in GitHub Desktop.
Save austa/06c887d308f098d7e1be to your computer and use it in GitHub Desktop.
package com.misona;
import java.sql.DriverManager;
import java.sql.SQLException;
import com.mysql.jdbc.Connection;
import com.mysql.jdbc.Statement;
public class Databaseİslem {
static final String HOST = "localhost:3306";
static final String DBNAME = "ogrenciDb";
static final String URI = "jdbc:mysql://" + HOST + "/" + DBNAME;
private boolean connectDatabase(String no, String ad, String soyad, String dogumtarihi, String bolumad) throws ClassNotFoundException, SQLException {
Class.forName("com.mysql.jdbc.Driver");
Connection con = (Connection) DriverManager.getConnection(URI,"root","cagatay");
Statement statement = (Statement) con.createStatement();
int kontrol =statement.executeUpdate("INSERT INTO duyuru(`no`, `ad`, `soyad`, `dogumtarihi`, `bolumad`) VALUES ('" +no+ "','" +ad+ "','" +soyad+ "','" +dogumtarihi+ "','" +bolumad+"')");
if (kontrol == 1) {
return true;
}else {
return false;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment