我有一個函數連接到數據庫 ,我有一個代碼,我有一個選擇和顯示元素在一個combobox中 所以我想傳遞類connexion.java combobox selectedItem因爲它包含所有的數據庫,我有 ,所以我想塔CLASSE的Connexion是動態的,所以通過對 我不此類選擇的元素「知道我怎麼能做到這一點,請幫助我使用combobox selectedItem函數
public class Connexion {
private static Connection conn;
{
try {
Class.forName("com.mysql.jdbc.Driver");
} catch (ClassNotFoundException ex) {
Logger.getLogger(Connexion.class.getName()).log(Level.SEVERE, null, ex);}
try {
conn = DriverManager.getConnection("jdbc:mysql://localhost/mohammedia", "root", "123456");
} catch (SQLException ex) {
Logger.getLogger(Connexion.class.getName()).log(Level.SEVERE, null, ex); }
}
public static Connection getconx()
{
return conn;
}
}
我讀的問題三次,可是我還是不知道你在問什麼。我建議你從添加點和大寫字母開始,使其更具可讀性。您還提到了一個組合框,但是它沒有顯示在您發佈的代碼中。總之,更清楚你實際要求的是什麼 – Robin
除了羅賓的建議之外,考慮發佈一個格式良好且正確縮進的代碼。爲了更好的幫助,請儘快發佈[SSCCE](http://sscce.org) –
Okey對不起,因爲我說得不太好英語 –