Java Connections
24 Kasım 2013 tarihinde Emre ÇİNTAŞ tarafından yazılmıştır.
Java veritabanı bağlantı class'ları
package YurtOtomasyon;
import java.sql.Connection;
import java.sql.DriverManager;
import javax.swing.JOptionPane;
public class oraclebaglantisi {
private static Connection baglanti = null;
public static Connection Baglan() {
try {
String url = "jdbc:oracle:thin:@127.0.0.1:1521:XE";
String surucu = "oracle.jdbc.OracleDriver";
String kullaniciAdi = "EMRE";
String kullaniciParolasi = "1234";
Class.forName(surucu);
baglanti = DriverManager.getConnection(url, kullaniciAdi, kullaniciParolasi);
return baglanti;
} catch (Exception e) {
JOptionPane.showMessageDialog(null, "HATA :" + e, "MESAJ", JOptionPane.ERROR_MESSAGE);
return null;
}
}
}
package YurtOtomasyon;
import java.sql.Connection;
import java.sql.DriverManager;
import javax.swing.JOptionPane;
@author
public class mysqlbaglantisi {
public static Connection Baglan() {
try {
Class.forName("com.mysql.jdbc.Driver");
Connection baglanti = DriverManager.getConnection("
jdbc:mysql://localhost:3306/yurtotomasyontakip?useUnicode=true&characterEncoding=UTF-8", "root", "");
return baglanti;
} catch (Exception e) {
JOptionPane.showMessageDialog(null, "HATA :" + e, "MESAJ", JOptionPane.ERROR_MESSAGE);
return null;
}
}
}
import java.sql.Connection;
import java.sql.DriverManager;
import javax.swing.JOptionPane;
public class accessbaglantisi {
private static Connection baglanti = null;
public static Connection Baglan() {
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
baglanti = DriverManager.getConnection("jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};"
+ "DBQ=C:Masraf Takip Yazılımıemremasraftakipdatabase.mdb ");
return baglanti;
} catch (Exception e) {
JOptionPane.showMessageDialog(null, "HATA :" + e, "MESAJ", JOptionPane.ERROR_MESSAGE);
return null;
}
}
}
package tr.com.emrecintas.sqlserver.baglantisi;
import java.sql.Connection;
import java.sql.DriverManager;
import javax.swing.JOptionPane;
public class sqlserverlbaglantisi {
private static Connection baglanti = null;
public static Connection Baglan() {
try {
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
baglanti = DriverManager.getConnection("jdbc:sqlserver://127.0.0.1:1433;
+ databaseName=emrcnts;user=emre;password=123);
return baglanti;
} catch (Exception e) {
JOptionPane.showMessageDialog(null, "HATA :" + e, "MESAJ", JOptionPane.ERROR_MESSAGE);
return null;
}
}
}