我的标准免责声明:我在大约10年内没有使用Java,所以我很可能在这里做了一些基本错误.
我正在为SmartFoxServer(SFS)编写一个"服务器端扩展" .在我的登录脚本中,我需要连接到MS SQL Server,我正在尝试使用JDBC.我在调试环境中测试了JDBC代码,它工作正常.
但
当我将服务器端扩展放在SFS"extensions"文件夹中时(根据规范),我得到一个com.microsoft.sqlserver.jdbc.SQLServerException
:
"此驱动程序未配置为集成身份验证."
我用Google搜索了这个错误,发现它通常是因为文件sqljdbc_auth.dll
不在系统路径中; 我已将此文件复制到系统路径中的文件夹中,但仍然无效!
还有其他建议吗?
有人可以指导我了解我需要在我的应用程序中包含哪个jar文件才能与ms sql server建立jdbc连接.
提前致谢.
我有一个Student
具有以下属性的类:
Name, Department, Address, Grade.
Run Code Online (Sandbox Code Playgroud)
现在我有一个ArrayList
包含这样的Student
对象,
List<Student> stuList = new ArrayList<Student>();
stuList.add(new Student("Tom","Comp", "123 street", "A"));
stuList.add(new Student("Jery","Comp", "456 street", "A+"));
stuList.add(new Student("Mac","Maths", "Dum Street", "B"));
Run Code Online (Sandbox Code Playgroud)
我需要将此arraylist传递给sql server存储过程并将student对象数据插入表中.如何在Java中实现这一目标?我需要有一个存储过程.
Java版本8,Sql Server 2014如果有任何用处.
我有一些访问SQL Server 2005的Java代码,如下所示:
CallableStatement cstmt = ...;
... // Set input parameters
cstmt.registerOutParameter(11, Types.INTEGER);
cstmt.execute();
int out = cstmt.getInt(11);
Run Code Online (Sandbox Code Playgroud)
从最后一行抛出以下异常:
com.microsoft.sqlserver.jdbc.SQLServerException: The value is not set
for the parameter number 0.
at com.microsoft.sqlserver.jdbc.SQLServerException.
makeFromDriverError(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerCallableStatement.
skipOutParameters(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerCallableStatement.
getOutParameter(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerCallableStatement.
getterGetParam(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerCallableStatement.
getInt(Unknown Source)
at org.jboss.resource.adapter.jdbc.WrappedCallableStatement.
getInt(WrappedCallableStatement.java:192)
Run Code Online (Sandbox Code Playgroud)
被调用的存储过程看起来像这样:
CREATE PROCEDURE dbo.stored_proc ( -- 10 input parameters
, @out_param INT OUTPUT) AS
-- Variable declarations
SET @out_param = 0
-- Do processing...
SET @out_param …
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用pyodbc将日期时间值插入到MS SQL Server表中.如果我手动执行,例如:
cursor.execute("""insert into currentvalue(value1,currentdatetime)
values(55,'2014-06-27 16:42:48.533')""")
Run Code Online (Sandbox Code Playgroud)
我没有任何问题,但是当我尝试做的时候:
currenttime = str(datetime.datetime.now())
cursor.execute("""insert into currentvalue(value1,currentdatetime)
values(55,"""+ currenttime+")")
Run Code Online (Sandbox Code Playgroud)
我收到了这个错误:
SQL服务器'07'附近的语法不正确,我认为这是日期和开始时间之后的数字.
我也试过这个:
currenttime = "'"+str(datetime.datetime.now())+"'"
Run Code Online (Sandbox Code Playgroud)
现在出现这个错误:
从字符串转换日期和/或时间时转换失败.
当我扫描数据库时,它显示诸如 VA1143 'dbo' 用户不应用于漏洞评估扫描中的正常服务操作之类的结果之一
他们建议“创建具有低权限的用户来访问数据库以及存储在其中的任何数据,并具有适当的权限集。”
我已经浏览了所有表格的相同内容,但还无法得到正确的建议。您能否提出您的想法或我必须在哪里创建用户并授予权限。因为我们的数据库中只有一种模式结构。
我在表TEST上触发了UPDATETRIGGER,
它被编写为在 TEST 表更新时被调用。
现在在此UPDATETRIGGER中更新同一TEST表的列。
这会递归吗?
我的触发器和表在 MS SQL 数据库中。从表中的值我看到它不会以这种方式发生,任何人都可以解释一下。
USE [TESTING]
GO
/****** Object: Trigger [dbo].[UPDATETRIGGER] ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER TRIGGER [dbo].[UPDATETRIGGER] on [dbo].[TEST]
FOR UPDATE
AS
UPDATE dbo.TEST
SET lastEditedDate=GetDate()
FROM INSERTED newdata
WHERE TEST.MasterK = newdata.MasterK
Run Code Online (Sandbox Code Playgroud) 尝试为sql server的nodejs构建microsoft驱动程序时出现以下错误
gyp信息如果以ok结束它是否有效
gyp info使用node-gyp@3.2.1
gyp info使用node@5.3.0 | win32 | 64位
gyp http GET https://nodejs.org/download/release/v5.3.0/node-v5.3.0-headers.tar.gz
gyp WARN安装出错,回滚安装
gyp ERR!配置错误
gyp ERR!堆栈错误:证书链中的自签名证书
gyp ERR!错误堆栈(本机)
gyp ERR!堆栈在TLSSocket.(_tls_wrap.js:1057:38)
gyp ERR!堆栈在emitNone(events.js:67:13)
gyp ERR!堆栈在TLSSocket.emit(events.js:166:7)
gyp ERR!堆栈在TLSSocket._fini
enter code here
shInitgyp ERR!不好 "
我尝试了下面的解决方法,但它工作
1) upgrade your version of npm
npm install npm -g --ca=null
- or -
2) tell your current version of npm to use known registrars
npm config set ca=""
Run Code Online (Sandbox Code Playgroud)
任何人都可以指导我如何解决此证书问题
我在WildFly 10服务器上运行我的应用程序.我不希望将我的连接细节放在我的应用程序src代码上,因此我试图将它放在WildFly 10服务器本身.
但是我遇到了问题.
在[WILDFLY_HOME]\modules\system\layers\base\com\microsoft
,我创建了以下目录sqlserver\main
,并将我的JAR文件和我的XML文件放在主文件夹中.
我正在使用的JAR是sqljdbc.jar
.
module.xml:
<?xml version="1.0" encoding="UTF-8"?>
<!-- JDBC Drivers module.xml file to configure your JDBC drivers-->
<!-- SQL Server 2014 example -->
<module xmlns="urn:jboss:module:1.3" name="com.microsoft.sqlserver">
<resources>
<resource-root path="sqljdbc.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
<module name="javax.transaction.api"/>
</dependencies>
</module>
Run Code Online (Sandbox Code Playgroud)
接下来[WILDFLY_HOME]\standalone\configuration
,我修改了standalone.xml
.在子系统数据源部分下,我添加了SQL Server的详细信息.
standalone.xml:
<subsystem xmlns="urn:jboss:domain:datasources:4.0">
<datasources>
<datasource jndi-name="java:jboss/datasources/ExampleDS" pool-name="ExampleDS" enabled="true" use-java-context="true">
<connection-url>jdbc:h2:mem:test;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE</connection-url>
<driver>h2</driver>
<security>
<user-name>sa</user-name>
<password>sa</password>
</security>
</datasource>
<datasource jndi-name="java:/TestDS" pool-name="TestDS" enabled="true" use-java-context="true">
<connection-url>jdbc:sqlserver://localhost\test:1433;databaseName=test</connection-url>
<driver>mssql</driver>
<security>
<user-name>sa</user-name>
<password>Password123!</password>
</security>
<pool> …
Run Code Online (Sandbox Code Playgroud) 我正在尝试在java.time
最新版本的 Sql Server JDBC 驱动程序中使用新类。正如我所读到的,它应该只适用于方法:PreparedStatement.setObject()
和ResultSet.getObject()
。
所以我创建了示例代码,但不能让它与 ResultSets 一起工作。我不知道我在这里做错了什么。
Connection connection = DriverManager.getConnection(connectionString);
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM myTable WHERE ? BETWEEN date_from AND date_to");
preparedStatement.setObject(1, LocalDateTime.now()); // That works
ResultSet resultSet = preparedStatement.executeQuery();
if (resultSet.next()) {
Object o = resultSet.getObject("date_from");
o.getClass() returns java.sql.Timestamp
LocalDateTime dateTime = resultSet.getObject("date_from", LocalDateTime.class);
}
Run Code Online (Sandbox Code Playgroud)
这会引发异常:
com.microsoft.sqlserver.jdbc.SQLServerException:不支持转换为类 java.time.LocalDateTime。
驱动版本:mssql-jdbc-6.5.4.jre8-preview.jar
SQL Server 版本:2016
如何解释底部表格中的这句话:
Java 8 中的新 Java 类:LocalDate/LocalTime/LocalDateTime、OffsetTime/OffsetDateTime
新的 JDBC 类型:TIME_WITH_TIMEZONE、TIMESTAMP_WITH_TIMEZONE、REF_CURSOR
REF_CURSOR is not supported in SQL Server. …
mssql-jdbc ×10
sql-server ×9
jdbc ×5
java ×4
sql ×2
node-gyp ×1
node.js ×1
npm ×1
protractor ×1
pyodbc ×1
python ×1
recursion ×1
server ×1
triggers ×1
wildfly ×1
wildfly-10 ×1