2种连接数据库和读取sql文件添加数据库和表
import java.io.*;
import java.sql.*;
public class DBConn {
private String ADDRESS ;
private int PORT ;
private String DBNAME ;
private String USERNAME ;
private String PASSWORD ;
private Connection conn ;
private PreparedStatement pstmt ;
private Statement stmt ;
private ResultSet rs ;
/***
* 连接MYSQL数据库
* @return
*/
public Connection getMySqlConn(){
try{
ADDRESS = "127.0.0.1";
PORT = 3306;
DBNAME = "test";
USERNAME = "root";
PASSWORD = "123456";
if(conn==null){
Class.forName("com.mysql.jdbc.Driver");
conn = DriverManager.getConnection("jdbc:mysql://"+ADDRESS+":"+PORT+"?user="+USERNAME+"&password="+PASSWORD+"&useUnicode=true&characterEncoding=utf8");
}
}catch(Exception e){
e.printStackTrace();
}
return conn;
}
/***
* 连接MSSQL数据库
* @return
*/
public Connection getMSSqlConn(){
try{
ADDRESS = "127.0.0.1";
PORT = 1433;
DBNAME = "mytest";
USERNAME = "sa";
PASSWORD = "";
if(conn==null){
Class.forName("net.sourceforge.jtds.jdbc.Driver");
conn = DriverManager.getConnection("jdbc:jtds:sqlserver://"+ADDRESS+":"+PORT,USERNAME,PASSWORD);
}
}catch(Exception e){
e.printStackTrace();
}
return conn;
}
/**
* 关闭数据库连接
* @return
*/
public void closeConn(){
try{
相关文档:
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Collections;
using System.Data.SqlClient;
/// <summary>
/// 数据库的通用访问代码
/// 此类为抽象类,不允许实例化,在应用时直接调用即可
/// </summary>
public ab ......
-->目录
-->SQL Server 构架
-->实施细则
-->最大容量说明
最大值(数量或大小)
对象 SQL Server 7.0 SQL Server 2000
批处理大小 65,536 * 网络数据包大小1 65,536 * 网络数据包大小1
每个短字符串列的字节数 8,000 8,000
每个 text、ntext、或 image 列的字节数 2 GB-2 2 GB-2
每个 GROU ......
SQL分页
万能分页
.net代码
select top 每页显示的记录数 * from topic where id not in
(select top (当前的页数-1)×每页显示的记录数 id from topic order by id desc)  ......
--行列互转
/******************************************************************************************************************************************************
以学生成绩为例子,比较形象易懂
整理人:中国风(Roy)
日期:2008.06.06
***************************************************************** ......
alter procedure qry_page
@sqlstr nvarchar(4000), --查询字符串
@page int, --第N页
@pagesize int &n ......