锘??xml version="1.0" encoding="utf-8" standalone="yes"?>
import聽
java.io.FileInputStream;
import聽
java.sql.Connection;
import聽
java.sql.DriverManager;
import聽
java.sql.PreparedStatement;
public聽class聽
InsertTextFileToMySQL聽
{
聽聽
public聽static聽
Connection聽getConnection
()聽
throws聽
Exception聽
{
聽聽聽聽
String聽driver聽=聽
"org.gjt.mm.mysql.Driver"
;
聽聽聽聽
String聽url聽=聽
"jdbc:mysql://localhost/databaseName"
;
聽聽聽聽
String聽username聽=聽
"root"
;
聽聽聽聽
String聽password聽=聽
"root"
;
聽聽聽聽
Class
.forName
(
driver
)
;
聽聽聽聽
Connection聽conn聽=聽DriverManager.getConnection
(
url,聽username,聽password
)
;
聽聽聽聽
return聽
conn;
聽聽
}
聽聽
public聽static聽
void聽
main
(
String
[]聽
args
)
throws聽
Exception聽
{
聽聽聽聽
String聽id聽=聽
"001"
;
聽聽聽聽
String聽fileName聽=聽
"fileName.txt"
;
聽聽聽聽
聽聽聽聽
FileInputStream聽fis聽=聽
null
;
聽聽聽聽
PreparedStatement聽pstmt聽=聽
null
;
聽聽聽聽
Connection聽conn聽=聽
null
;
聽聽聽聽
try聽
{
聽聽聽聽聽聽
conn聽=聽getConnection
()
;
聽聽聽聽聽聽
conn.setAutoCommit
(
false
)
;
聽聽聽聽聽聽
File聽file聽=聽
new聽
File
(
fileName
)
;
聽聽聽聽聽聽
fis聽=聽
new聽
FileInputStream
(
file
)
;
聽聽聽聽聽聽
pstmt聽=聽conn.prepareStatement
(
"insert聽into聽DataFiles(id,聽fileName,聽fileBody)聽values聽(?,聽?,聽?)"
)
;
聽聽聽聽聽聽
pstmt.setString
(
1
,聽id
)
;
聽聽聽聽聽聽
pstmt.setString
(
2
,聽fileName
)
;
聽聽聽聽聽聽
pstmt.setAsciiStream
(
3
,聽fis,聽
(
int
)聽
file.length
())
;
聽聽聽聽聽聽
pstmt.executeUpdate
()
;
聽聽聽聽聽聽
conn.commit
()
;
聽聽聽聽
}聽
catch聽
(
Exception聽e
)聽{
聽聽聽聽聽聽
System.err.println
(
"Error:聽"聽
+聽e.getMessage
())
;
聽聽聽聽聽聽
e.printStackTrace
()
;
聽聽聽聽
}聽
finally聽
{
聽聽聽聽聽聽
pstmt.close
()
;
聽聽聽聽聽聽
fis.close
()
;
聽聽聽聽聽聽
conn.close
()
;
聽聽聽聽
}
聽聽
}
}
declare @data_0 varchar(100)
declare @date_1 varchar(100)
declare @date_2 varchar(100)
declare @yvisit integer
declare @yadd integer
declare @mvisit integer
declare @madd integer
set @data_0=convert(char(8),getdate(),112)
set @data_1=convert(char(8),dateadd(day,-1,getdate()),112)
set @date_2=left(convert(char(30),dateadd(day,-1,getdate()),121),10)
print @temp_0
print @temp_1
print @temp_2
select @yvisit=count(distinct(mid)) from dbo.wap_log_access_2006_6 where uri='/wap/pd/yysl_yk/index.jsp'
and mid != ''
and create_time >= '2006-06-06 00:00:00'
and create_time <= '2006-06-06 23:59:59'
select @mvisit=count(distinct(mid)) from dbo.wap_log_access_2006_6 where uri='/wap/pd/mlmhc_yk/index.jsp'
and mid != ''
and create_time >= '2006-06-06 00:00:00'
and create_time <= '2006-06-06 23:59:59'
select @yadd=count(distinct(mid)) from dbo.wap_log_fee_2006_6 as a
where a.uri='/wap/pd/yysl_yk/get.jsp'
and a.mid != ''
and a.portal_id=0
and a.create_time >= '2006-06-06 00:00:00'
and a.create_time <= '2006-06-06 23:59:59'
and exists(select * from dbo.wapuser as b where a.mid = b.mid and b.serviceid='30050631'
and b.firsttime >= '2006-06-06 00:00:00'
and b.firsttime <= '2006-06-06 23:59:59')
select @madd=count(distinct(mid)) from dbo.wap_log_fee_2006_6 as a
where a.uri='/wap/pd/mlmhc_yk/get.jsp'
and a.mid != ''
and a.portal_id=0
and a.create_time >= '2006-06-06 00:00:00'
and a.create_time <= '2006-06-06 23:59:59'
and exists(select * from dbo.wapuser as b where a.mid = b.mid and b.serviceid='02011095'
and b.firsttime >= '2006-06-06 00:00:00'
and b.firsttime <= '2006-06-06 23:59:59')
insert into wap_data_content_zf wap(date,mvisit,madd,yvisit,yadd)
聽聽聽聽聽聽 values(@temp_2,@mvisit,@madd,@yvisit,@yadd)
declare聽 case1聽聽聽 cursor for聽
聽聽聽 SELECT mid,service_id from bird_user_2006_03 where type=0聽
declare聽 case2聽聽聽 cursor for聽
聽聽聽 SELECT mid,service_id from bird_user_2006_03 where type=1
聽
open case1
聽 fetch next from case1 into @mid,@service_id
聽 while (@@fetch_status=0)
聽聽聽 begin
聽聽聽聽聽聽聽 select top 1聽 @actionid=bb.actionid from聽 operation_temp_0526 as bb
聽聽聽聽聽聽聽聽聽聽聽聽聽聽 where bb.serviceid=@service_id and bb.mid=@mid
聽聽聽聽聽聽聽 order by bb.id desc
聽聽聽聽 if (@actionid=1)聽聽聽聽聽聽聽聽
聽聽聽聽聽聽聽 insert into bird_user_2006_04(mid,service_id,type,portal_id) values(@mid,@service_id,'1','10000')
聽聽聽聽 else
聽聽聽聽聽聽聽聽 print 'ooooooo'聽聽聽聽聽
聽聽聽聽聽聽聽 fetch next from case1 into @mid,@service_id
聽聽 end
deallocate case1
open case2
聽 fetch next from case2 into @mid,@service_id
聽 while (@@fetch_status=0)
聽聽聽 begin
聽聽聽聽聽聽聽 select聽 top 1 @actionid=bb.actionid from聽 operation_temp_0526 as bb
聽聽聽聽聽聽聽聽聽聽聽聽聽聽 where bb.serviceid=@service_id and bb.mid=@mid
聽聽聽聽聽聽聽 order by bb.id desc
聽聽聽聽 if (@actionid != 2)聽聽聽聽聽聽聽聽聽聽
聽聽聽聽聽聽聽 insert into bird_user_2006_04(mid,service_id,type,portal_id) values(@mid,@service_id,'2','10000')
聽聽聽聽聽聽聽 fetch next from case2 into @mid,@service_id
聽聽 end
deallocate case2
GO
select * from Meeting where convert(varchar(10),PublishTime,121))=@PublishTime,榪欐牱鍦ㄦ煡璇㈡椂鏁版嵁搴撳緱鍒板弬鏁板悗鍏堣嚜鍔ㄥ皢鏁版嵁搴撳唴鐨勪俊鎭漿鎹負yyyy-mm-dd鏍煎紡鐨?0浣嶅瓧絎?鍙涓庡弬鏁扮浉鍚屽嵆鍙繑鍥炴煡璇㈢粨鏋?鑰宑onvert涓殑121鏄寚灝哾atetime綾誨瀷杞崲涓篶har綾誨瀷鏃惰幏寰楀寘鎷笘綰綅鏁扮殑4浣嶅勾浠?br />
鏍煎紡:
CONVERT(data_type,expression[,style])
璇存槑:
姝ゆ牱寮忎竴鑸湪鏃墮棿綾誨瀷(datetime,smalldatetime)涓庡瓧絎︿覆綾誨瀷(nchar,nvarchar,char,varchar)
鐩鎬簰杞崲鐨勬椂鍊欐墠鐢ㄥ埌.
渚嬪瓙:
Select CONVERT(varchar(30),getdate(),101) now
緇撴灉涓?br />now
---------------------------------------
09/15/2001
/////////////////////////////////////////////////////////////////////////////////////
style鏁板瓧鍦ㄨ漿鎹㈡椂闂存椂鐨勫惈涔夊涓?br />
-------------------------------------------------------------------------------------------------
Style(2浣嶈〃紺哄勾浠? | Style(4浣嶈〃紺哄勾浠? | 杈撳叆杈撳嚭鏍煎紡
-------------------------------------------------------------------------------------------------
- | 0 or 100 | mon dd yyyy hh:miAM(鎴朠M)
-------------------------------------------------------------------------------------------------
1 | 101 | mm/dd/yy
-------------------------------------------------------------------------------------------------
2 | 102 | yy-mm-dd
-------------------------------------------------------------------------------------------------
3 | 103 | dd/mm/yy
-------------------------------------------------------------------------------------------------
4 | 104 | dd-mm-yy
-------------------------------------------------------------------------------------------------
5 | 105 | dd-mm-yy
-------------------------------------------------------------------------------------------------
6 | 106 | dd mon yy
-------------------------------------------------------------------------------------------------
7 | 107 | mon dd,yy
-------------------------------------------------------------------------------------------------
8 | 108 | hh:mm:ss
-------------------------------------------------------------------------------------------------
- | 9 or 109 | mon dd yyyy hh:mi:ss:mmmmAM(鎴朠M)
-------------------------------------------------------------------------------------------------
10 | 110 | mm-dd-yy
-------------------------------------------------------------------------------------------------
11 | 111 | yy/mm/dd
-------------------------------------------------------------------------------------------------
12 | 112 | yymmdd
-------------------------------------------------------------------------------------------------
- | 13 or 113 | dd mon yyyy hh:mi:ss:mmm(24灝忔椂鍒?
-------------------------------------------------------------------------------------------------
14 | 114 | hh:mi:ss:mmm(24灝忔椂鍒?
-------------------------------------------------------------------------------------------------
- | 20 or 120 | yyyy-mm-dd hh:mi:ss(24灝忔椂鍒?
-------------------------------------------------------------------------------------------------
- | 21 or 121 | yyyy-mm-dd hh:mi:ss:mmm(24灝忔椂鍒?
-------------------------------------------------------------------------------------------------
浠ヤ笂鏄垜鍦ㄥ紑鍙戜腑閬囧埌鐨勫皬鍥伴毦鐨勬葷粨,濡傛灉鍐欑殑鏈変笉姝g‘鐨勫湴鏂規榪庡ぇ瀹舵寚鏁?