ARAMA

Değerlilerim

Java Connections

24 Kasım 2013 tarihinde Emre ÇİNTAŞ tarafından yazılmıştır.

Java veritabanı bağlantı class'ları

JAVA - ORACLE
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 {      // jdbc:oracle:thin:@localhost:1521:XE
            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);


//           JOptionPane.showMessageDialog(null, "BAŞARILI BAĞLANTI KURULDU", "MESAJ",
//                JOptionPane.INFORMATION_MESSAGE);

            return baglanti;
        } catch (Exception e) {
            JOptionPane.showMessageDialog(null, "HATA :" + e, "MESAJ", JOptionPane.ERROR_MESSAGE);
            return null;
        }
    }
}

JAVA - MYSQL
package YurtOtomasyon;

import java.sql.Connection;
import java.sql.DriverManager;
import javax.swing.JOptionPane;

/**
 *
 * @author Emre ÇİNTAŞ
 */
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; } } }
JAVA - ACCESS

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:AccessVeritabani2007DSN");                                                                                

            baglanti = DriverManager.getConnection("jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};"
                    + "DBQ=C:Masraf Takip Yazılımıemremasraftakipdatabase.mdb ");


//            JOptionPane.showMessageDialog(null, "BAŞARILI BAĞLANTI KURULDU", "MESAJ",
//                 JOptionPane.INFORMATION_MESSAGE);

            return baglanti;
        } catch (Exception e) {
            JOptionPane.showMessageDialog(null, "HATA :" + e, "MESAJ", JOptionPane.ERROR_MESSAGE);
            return null;
        }
    }
}

JAVA - SQL SERVER
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;
        }
    }
}