小编mut*_*mar的帖子

使用SQL Server数据库中的脚本删除主键

我需要删除StudentSQL Server数据库中表的主键.

我已经在表格中编辑了,我得到的脚本是

ALTER TABLE dbo.Student
    DROP CONSTRAINT PK__Student__9CC368536561EF8B
Run Code Online (Sandbox Code Playgroud)

但是当我在SQL Server查询浏览器中运行此脚本以删除主键时

它显示了该消息

Msg 3728,Level 16,State 1,Line
1'PK__Student__9CC368536561EF8B'不是约束.
Msg 3727,Level 16,State 0,Line 1

令我担心的是,我认为PK__Student__9CC368536561EF8B这将随机生成,请帮助我使用脚本删除主键约束.

提前致谢

sql-server sql-server-2005 sql-server-2008

43
推荐指数
3
解决办法
13万
查看次数

使用Java获取给定excel中特定行的列数

我想要excel中特定行的列数.怎么可能?我使用了POI API

但我只能将列数计算为7.

    try
            {
                fileInputStream = new FileInputStream(file);
                workbook = new HSSFWorkbook(fileInputStream);
                Sheet sheet = workbook.getSheet("0");


                int numberOfCells = 0;
                Iterator rowIterator = sheet.rowIterator();
                /**
                 * Escape the header row *
                 */
                if (rowIterator.hasNext())
                {
                    Row headerRow = (Row) rowIterator.next();
                    //get the number of cells in the header row
                    numberOfCells = headerRow.getPhysicalNumberOfCells();
                }
                System.out.println("number of cells "+numberOfCells);

}
Run Code Online (Sandbox Code Playgroud)

我希望特定行号的列数为10.excel列不相同

java excel apache-poi

34
推荐指数
1
解决办法
10万
查看次数

在JTA配置中设置超时

JTA事务意外地回滚(可能是由于超时); 嵌套异常是

javax.transaction.RollbackException: The transaction was set to rollback only
Run Code Online (Sandbox Code Playgroud)

由于JPA,我收到超时异常:如何增加交易所需的时间?

我应该在哪里包含参数来解决这个问题?

我正在使用tomcat 7.

java jta tomcat7

4
推荐指数
1
解决办法
6119
查看次数

从字符串中分隔数字

我想得到给定字符串的数字,我使用下面的代码

String sample = "7011WD";
    String output = "";
    for (int index = 0; index < sample.length(); index++)
    {
        if (Character.isDigit(sample.charAt(index)))
        {
            char aChar = sample.charAt(index);
            output = output + aChar;
        }
    }

    System.out.println("output :" + output);
Run Code Online (Sandbox Code Playgroud)

结果是: 输出:7011

有没有简单的方法来获得输出?

java

1
推荐指数
1
解决办法
149
查看次数