⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 trysqlwarning.java

📁 此程序都是企业级 的数据库开发程序 全面揭示了JAVA对数据库的操作
💻 JAVA
字号:
import java.sql.*;public class TrySQLWarning{	  public static void main(String[] args)	  {			String url = "jdbc:cloudscape:Wrox4370.db";			String driver = "COM.cloudscape.core.JDBCDriver";			String username = "guest";			String password = "guest";			String theStatement =			   "SELECT recordingid, recordingtitle, listprice FROM recordings";			try			{				Class.forName(driver);				Connection connection = DriverManager.getConnection(url, username, password);				Statement queryRecordings = connection.createStatement();				ResultSet theResults =  queryRecordings.executeQuery(theStatement);				while(theResults.next())				{					int id, price;					String title;					id = theResults.getInt("recordingid");					checkForWarning(theResults.getWarnings());					title = theResults.getString("recordingtitle");					checkForWarning(theResults.getWarnings());					price = theResults.getInt("listprice");					checkForWarning(theResults.getWarnings());					System.out.println(id + ", " + title + ", " + price);				}			    queryRecordings.close();		    }			catch (ClassNotFoundException cnfe)	    	{			    System.out.println(cnfe);		    }			catch (SQLException sqle)	    	{				do // loop through each exception				{					// do something with each exception					System.err.println("Exception occurred:\nMessage: " + sqle.getMessage());					System.err.println("SQL state: " + sqle.getSQLState());					System.err.println("Vendor code: " + sqle.getErrorCode() +								 "\n----------------");				} while((sqle = sqle.getNextException()) != null);		    }		}	static boolean checkForWarning(SQLWarning w)	{		if(w == null)			return false;		do		{			System.err.println("Warning:\nMessage: " + w.getMessage());			System.err.println("SQL state: " + w.getSQLState());			System.err.println("Vendor code: " + w.getErrorCode() +							   "\n----------------");		}while((w = w.getNextWarning())!=null);		return true;	}}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -