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

📄 testsql.java

📁 一个新闻系统。你可以根据系统的功能提交新的新闻
💻 JAVA
字号:
package lab;
import java.sql.*;

public class TestSql {

	/**
	 * @param args
	 */
	private String url = "jdbc:odbc:testSql";
	private Statement stmt; 
	private Connection con;
	public void init() throws SQLException, ClassNotFoundException
	{		
				Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
				//加载jdbc-odbc桥驱动 
				this.getConnected();
				this.createStatement();		
	}
	public void getConnected() throws SQLException
	{
		
			 this.con=DriverManager.getConnection(url,"sa","");
             //取得连接的url名,注意testSql是dsn名,需自己建立
	}
	public void createStatement() throws SQLException
	{
			   stmt=con.createStatement();
	}
	public ResultSet executeQuery(String query) throws SQLException
	{
		ResultSet rs=null;
		
			 rs=stmt.executeQuery(query);
		return rs;
	}
	public int executeUpdate(String updateString) throws SQLException
	{
		int rs=0;
		
			rs = this.stmt.executeUpdate(updateString);
		return rs;
	}
	public void getClosed() throws SQLException
	{		
				stmt.close();
				con.close();		
	} 
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		
	}

}

⌨️ 快捷键说明

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