易截截图软件、单文件、免安装、纯绿色、仅160KB

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{
   


相关文档:

SQL SERVER中交和差的实现

create table aaa
(
id int primary key ,
name varchar(30) not null
)
create table bbb
(
id int primary key ,
name varchar(30) not null
)
--交
select * from aaa
where exists
(
select * from bbb where aaa.id=bbb.id and aaa.name = bbb.name
)
--差
select *
from bbb
where not exists
( ......

理解SQL SERVER中所有者和架构的区别

理解SQL SERVER中所有者和架构的区别
SQL SERVER2005介绍了架构,架构相对于以前版本中的对象所有者。本文将解释这两者的区别,并希望能解开你至今仍对架构一点困惑。
对象所有者
要理解所有者和架构之间的区别,让我们先花点时间来复习一下对象的所有权。在SQL SERVER2000或以前版本中创建一个对象,对象必须要有一个所 ......

国外空间Sql数据乱码问题

国外空间貌似对中文比较感冒 如果数据类型设计为 varchar 类型的话 存储的数据基本上是  "????"
很简单 将 varchar 类型 设计为 nvarchar 类型
create table cs
(
   txt1 nvarchar(50) null
)
insert into cs (txt1 ) values ('测试')  -- 入库时数据时 ????
insert into cs (txt ......

SQL分页


SQL分页
万能分页
.net代码
select top 每页显示的记录数 * from topic where id not in     
 (select top (当前的页数-1)×每页显示的记录数 id from topic order by id desc)  ......

Orcale 的SQL 语句取得系统当前时间用:sysdate

Orcale 的SQL 语句取得系统当前时间用:sysdate
    当需要在系统当前日期上减去一天时可以用   sysdate-1
     附:当只对一定数量的记录感兴趣时可以如 rownum<100
select * from SLYC_CUSTINFO_T where indbtime>sysdate-1 and OFFICE_CODE='46' and rownum<1 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号