queria aplicar o modelo do singleton nesse codigo aqui que faz conexão com um banco de dados acess!!
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author Adauto
*/
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package massa;
import java.sql.*;
import javax.swing.*;
/**
*
*/
public class clsBancoDeDados {
static Connection conexao;
static Statement comando;
static ResultSet rs;
//ALUNOS
static Integer codaluno;
static Integer codmodalidade;
static Integer codpromocao;
/*static String nomealuno;
static Date datanasc;
static String profissao;
static String endereco;
static String nro;
static String apto;
static String bairro;
static String telefone;
static String celular;*/
public static void main(String args[]) throws InstantiationException, IllegalAccessException, UnsupportedLookAndFeelException {
try {
//PARA COLOCAR O FORMATO WINDOWS
try {
UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
//Para Setar as opções Yes=Sim e No=Não
UIManager.put("OptionPane.yesButtonText", "Sim");
UIManager.put("OptionPane.noButtonText", "Não");
} catch (ClassNotFoundException classNotFoundException) {
} catch (InstantiationException instantiationException) {
} catch (IllegalAccessException illegalAccessException) {
} catch (UnsupportedLookAndFeelException unsupportedLookAndFeelException) {
}
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
conexao = DriverManager.getConnection("jdbc:odbc:bdEngenharia");
comando = conexao.createStatement();
//testa danco
rs = comando.executeQuery("select * from login");
while (rs.next()) {
System.out.println(rs.getString("usuario"));
System.out.println(rs.getString("senha"));
System.out.println(rs.getString("permissao"));
}
// rs = comando.executeQuery("select * from dados");
//while (rs.next()) {
//System.out.println(rs.getString("nome"));
//System.out.println(rs.getString("dados"));
//}
} catch (ClassNotFoundException e) {
JOptionPane.showMessageDialog(null,
"Erro de Conexao com Banco de Dados" + e);
} catch (SQLException e) {
JOptionPane.showMessageDialog(null,
"Erro de Sintaxe SQL" + e);
}
frmLogin login = new frmLogin();
login.setVisible(true);
}
;
}