在tomcat中,数据库连接在部分执行之间关闭

时间:2015-07-10 18:49:50

标签: database tomcat

在tomcat中,数据库连接在部分执行之间关闭,获取java.net.Connection:拒绝连接。任何操作的异常都不一致,它在不同的间隔之间抛出。有人可以帮忙吗?

由于

1 个答案:

答案 0 :(得分:0)

如果OBJECT_ID(' sysGenerateInsert',' P')IS NOT NULL 开始     DROP PROC sysGenerateInsert     PRINT' sysGenerateInsert SP成功删除' 结束 GO

CREATE PROC sysGenerateInsert(@TblName varchar(128)) 如 开始     -------------------------------------------------- ---------------      - 目的:为给定的表生成INSERT语句      - *多线插入      - *复制生成的脚本并删除最后一个逗号      - 并执行      -      - 用法:EXEC sysGenerateInsert' TableName'      -      - 创建人:Guruprasad On:2010年1月3日     -------------------------------------------------- ---------------     CREATE TABLE #ColumnMetaData(         Id INT IDENTITY(1,1),         IsChar INT,         ColName VARCHAR(128)     )

IF NOT EXISTS (SELECT * 
                 FROM INFORMATION_SCHEMA.COLUMNS
                WHERE  TABLE_NAME = @TblName)
BEGIN
    RAISERROR('No columns found for table %s or Table not exist', 16,-1, @TblName)
    RETURN
END

INSERT  #ColumnMetaData (IsChar, ColName)
SELECT CASE WHEN DATA_TYPE LIKE '%char%' 
            THEN 1 
            ELSE 0 END IsChar,
       COLUMN_NAME     ColName
FROM   INFORMATION_SCHEMA.COLUMNS
WHERE  TABLE_NAME = @TblName
ORDER BY ORDINAL_POSITION

DECLARE @InsertIntoStmt VARCHAR(MAX),
        @InsertIntoData VARCHAR(MAX)

SELECT @InsertIntoStmt = 'SELECT '' INSERT INTO ' + @TblName + ' ( '
SELECT @InsertIntoData = 'SELECT ''(''+' 

SELECT  @InsertIntoStmt = @InsertIntoStmt + ColName + ','
FROM    #ColumnMetaData

SELECT @InsertIntoData =    @InsertIntoData
        + ' CASE WHEN ' + ColName + ' IS NULL '
        +   ' THEN ''NULL'' '
        +   ' ELSE '
        +     CASE WHEN IsChar = 1 
                   THEN  ''''''''' + ' + ColName + ' + ''''''''' 
                   ELSE 'CONVERT(VARCHAR(20),' + ColName + ')' 
              END
        + ' END + '','' + '
FROM    #ColumnMetaData

SELECT @InsertIntoStmt = LEFT(@InsertIntoStmt,LEN(@InsertIntoStmt)-1) + ' )  VALUES ''' 
SELECT @InsertIntoData = LEFT(@InsertIntoData,LEN(@InsertIntoData)-8) + ' + ''),'' FROM ' + @tblName

EXEC (@InsertIntoStmt + ' UNION ALL ' + @InsertIntoData)

DROP TABLE #ColumnMetaData

END 去

PRINT' sysGenerateInsert SP已成功创建'