try {
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
String connectionUrl = "jdbc:sqlserver://"+hostName.getText()+";" +
"databaseName="+dbName.getText()+";user="+userName.getText()+";password="+password.getText()+";";
Connection con = DriverManager.getConnection(connectionUrl);
if(con!=null){JOptionPane.showMessageDialog(this, "Connection Established");}
} catch (SQLException e) {
JOptionPane.showMessageDialog(this, e);
//System.out.println("SQL Exception: "+ e.toString());
} catch (ClassNotFoundException cE) {
//System.out.println("Class Not Found Exception: "+ cE.toString());
JOptionPane.showMessageDialog(this, cE.toString());
}
Khi có lỗi, nó hiển thị hộp tin nhắn JOptionPane dài hơn chiều rộng của màn hình máy tính. Làm thế nào tôi có thể phá vỡ e.toString() thành hai hoặc nhiều phần.Để ngắt thư trong hai hoặc nhiều dòng trong JOptionPane
Đặt xuống dòng (\ n) nhân vật. – adatapost