Created
June 17, 2014 14:59
-
-
Save austa/06c887d308f098d7e1be to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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