gpt4 book ai didi

java - 将 Eclipse 连接到 SQL Server 时出错

转载 作者:行者123 更新时间:2023-12-02 05:45:13 26 4
gpt4 key购买 nike

这是语法错误

Jun 10, 2014 5:15:51 PM org.apache.catalina.core.AprLifecycleListener
init
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on
the java.library.path: C:\Program Files
(x86)\Java\jre7\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:/Program
Files (x86)/Java/jre7/bin/client;C:/Program Files
(x86)/Java/jre7/bin;C:/Program Files
(x86)/Java/jre7/lib/i386;C:\Program Files (x86)\NVIDIA
Corporation\PhysX\Common;C:\Program Files (x86)\Intel\iCLS
Client\;C:\Program Files\Intel\iCLS Client\;C:\Program Files (x86)\AMD
APP\bin\x86_64;C:\Program Files (x86)\AMD APP\bin\x86;C:\Program
Files\Common Files\Microsoft Shared\Windows Live;C:\Program Files
(x86)\Common Files\Microsoft Shared\Windows
Live;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program
Files (x86)\Windows Live\Shared;C:\Program Files (x86)\ATI
Technologies\ATI.ACE\Core-Static;C:\Program Files\Intel\Intel(R)
Management Engine Components\DAL;C:\Program Files\Intel\Intel(R)
Management Engine Components\IPT;C:\Program Files (x86)\Intel\Intel(R)
Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R)
Management Engine Components\IPT;C:\Program Files\Microsoft\Web
Platform Installer\;C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET
Web Pages\v1.0\;C:\Program Files (x86)\Windows Kits\8.0\Windows
Performance Toolkit\;C:\Program Files\Microsoft SQL
Server\110\Tools\Binn\;C:\Program Files (x86)\Microchip\MPLAB C32
Suite\bin;C:\Program Files\Java\jdk1.7.0_25\bin;C:\Program Files
(x86)\Java\jdk1.7.0_03\bin;c:\Program Files (x86)\Microsoft SQL
Server\100\Tools\Binn\VSShell\Common7\IDE\;c:\Program Files
(x86)\Microsoft SQL Server\100\Tools\Binn\;c:\Program Files\Microsoft
SQL Server\100\Tools\Binn\;c:\Program Files (x86)\Microsoft SQL
Server\100\DTS\Binn\;c:\Program Files\Microsoft SQL
Server\100\DTS\Binn\;C:\Program Files
(x86)\Google\google_appengine\;C:\Users\Patrick\Desktop\2013-2014 2nd
Sem Files\Eclipsee\eclipse;;. Jun 10, 2014 5:15:51 PM
org.apache.tomcat.util.digester.SetPropertiesRule begin WARNING:
[SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting
property 'source' to 'org.eclipse.jst.jee.server:B2B' did not find a
matching property. Jun 10, 2014 5:15:51 PM
org.apache.coyote.AbstractProtocol init INFO: Initializing
ProtocolHandler ["http-bio-8080"] Jun 10, 2014 5:15:51 PM
org.apache.coyote.AbstractProtocol init INFO: Initializing
ProtocolHandler ["ajp-bio-8009"] Jun 10, 2014 5:15:51 PM
org.apache.catalina.startup.Catalina load INFO: Initialization
processed in 544 ms Jun 10, 2014 5:15:51 PM
org.apache.catalina.core.StandardService startInternal INFO: Starting
service Catalina Jun 10, 2014 5:15:51 PM
org.apache.catalina.core.StandardEngine startInternal INFO: Starting
Servlet Engine: Apache Tomcat/7.0.42 Jun 10, 2014 5:15:52 PM
org.apache.coyote.AbstractProtocol start INFO: Starting
ProtocolHandler ["http-bio-8080"] Jun 10, 2014 5:15:52 PM
org.apache.coyote.AbstractProtocol start INFO: Starting
ProtocolHandler ["ajp-bio-8009"] Jun 10, 2014 5:15:52 PM
org.apache.catalina.startup.Catalina start INFO: Server startup in 374
ms com.microsoft.sqlserver.jdbc.SQLServerException: Incorrect syntax
near '`'.

这是我的代码

package b2b.fishermall;

public class ConnectionString extends SqlStringCommands
{
public String getDriver()
{
return "com.microsoft.sqlserver.jdbc.SQLServerDriver";
}
public String getURL()
{
return "jdbc:sqlserver://localhost:1433;databaseName=B2B;integratedSecurity=true;";
}
public String getUsername()
{
return "";
}
public String getDbPassword()
{
return "";
}
}

最佳答案

你的代码不好。不要这样做。

当三个静态最终字符串可以完美地完成任务时,代码量就很大了。更好的是,你应该将这些东西具体化。

没有数据库用户名或密码?哦,我的天。

如果您使用 Tomcat,正确的做法是使用 JNDI 连接池。 Tomcat有detailed docs向您展示如何操作。

让我再猜测一下:您正在编写带有 scriptlet 的 JSP。又一个“不要做”。如果必须使用 JSP,请学习 JSTL。

我无法从堆栈跟踪中看出任何信息。还有什么吗?

关于java - 将 Eclipse 连接到 SQL Server 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24137297/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com