/** * @param out the place to write to * @param warning the SQLWarning */ public static void ShowWarnings(PrintWriter out, SQLWarning warning) { while (warning != null) { String p1 = mapNull(warning.getSQLState(), LocalizedResource.getMessage("UT_NoSqlst_7")); String p2 = mapNull(warning.getMessage(), LocalizedResource.getMessage("UT_NoMessa_8")); out.println(LocalizedResource.getMessage("UT_Warni01", p1, p2)); warning = warning.getNextWarning(); } }
public static void ShowWarnings(PrintStream out, SQLWarning warning) { while (warning != null) { out.println( "WARNING " + mapNull(warning.getSQLState(), "(no SQLState)") + ": " + mapNull(warning.getMessage(), "(no message)")); warning = warning.getNextWarning(); } }
// Format and print any warnings from the connection private static void checkForWarning(SQLWarning warn) throws SQLException { // If a SQLWarning object was given, display the // warning messages. Note that there could be // multiple warnings chained together if (warn != null) { System.out.println("*** Warning ***\n"); while (warn != null) { System.out.println("SQLState: " + warn.getSQLState()); System.out.println("Message: " + warn.getMessage()); System.out.println("Vendor: " + warn.getErrorCode()); System.out.println(""); warn = warn.getNextWarning(); } } }
public void connect() { try { // Load the database driver Class.forName("net.sourceforge.jtds.jdbc.Driver"); // Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver").newInstance(); // Get a connection to the database String url = "jdbc:jtds:sqlserver://147.87.98.131:55783"; conn = DriverManager.getConnection(url, "se2012_red", "Thanuc57ch"); // Get a statement from the connection stmt = conn.createStatement(); // Print all warnings for (SQLWarning warn = conn.getWarnings(); warn != null; warn = warn.getNextWarning()) { System.out.println("SQL Warning:"); System.out.println("State : " + warn.getSQLState()); System.out.println("Message: " + warn.getMessage()); System.out.println("Error : " + warn.getErrorCode()); } } catch (SQLException se) { System.out.println("SQL Exception:"); // Loop through the SQL Exceptions while (se != null) { System.out.println("State : " + se.getSQLState()); System.out.println("Message: " + se.getMessage()); System.out.println("Error : " + se.getErrorCode()); se = se.getNextException(); } } catch (Exception e) { System.out.println(e); } }