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{
Ïà¹ØÎĵµ£º
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 2000Êý¾Ý¿âËð»µÁËÖØ×°ºó¶¼·¢ÉúÁËͬÑùµÄÎÊÌ⣬ÄǾÍÊÇ°²×°SQL SERVERÊý¾Ý¿â²»³É¹¦¡£ÔÒò£º¼´Ê¹Äãͨ¹ý¿ØÖÆÃæ°åÀïµÄ“Ìí¼Ó/ɾ³ý³ÌÐò” Õý³£µÄжÔØSQL SERVERÊý¾Ý¿â£¬µ«ÊÇ£¬SQL SERVER»¹ÊÇûÓÐÍêȫжÔظɾ»£¬»¹ÐèÒªÊÖ¹¤½øÐÐһЩ²Ù×÷¡£Òò´ËÖØа²×°²»³É¹¦£¬º ......
sql serverÊý¾Ý¿â±¸·Ý·½°¸
2008-08-05 13:15
SQL Server Êý¾Ý¿â±¸·Ý·½°¸
ΪÁ˱£Ö¤SQL Server Êý¾ÝµÄ°²È«£¬Êý¾Ý¿â¹ÜÀíÔ±Ó¦¶¨ÆÚ±¸·ÝÊý¾Ý¿â£¬ÔÚ²»Í¬Çé¿öÏÂÓ¦²ÉÓò»Í¬±¸·ÝÊý¾Ý¿â±¸·Ý²ßÂÔ£¬Ò»·½Ãæά³ÖÊý¾ÝµÄ°²È«ÐÔ£¬ÁíÒ»·½ÃæÒ²¿É±£³ÖSQL Server ÄÜ˳³©ÔËÐС£¾¡×î´óµÄŬÁ¦¼õÉÙÓÉÓÚÊý¾ÝµÄË𻵶Կͻ§Ôì³ÉµÄËðʧ¡£
¸ÅÄî
1) ±¸·Ý ......
string s = " 80,81,83,82";
string[] s1 = s.Split(',');
int[] p = new int[s1.Count()];
for (int i = 0; i < s1.Count( ......