讓我說,編譯代碼庫時,一切工作正常啓動了,我可以連接到SQL Server Express的2012數據庫。問題:JavaFX的部署與外部JDBC JAR文件
我是,當我創建一個Windows可執行文件和eventhough的Sqljdbc41.jar包含在分佈,即位於以下文件夾"myProject\app\lib\sqljdbc41.jar"
我的應用程序似乎無法找到這個瓶子文件進行連接。我得到拋出以下異常:
注:在編譯我的Netbeans的代碼庫時,被安裝在開發機器上我的應用程序在安裝後測試它只有當出現此異常不會出現。
java.sql.SQLException: No suitable driver
found for jdbc:sqlserver://localhost:1433;databaseName=NORTHWND;
我使用NetBeans 8.0.1具有以下設置:
在工具 - >選項在Java螞蟻選項卡下我有這樣幾種:
C:\Users\Zermatt\Documents\NetBeansProjects\myProject\src\myProject\Microsoft\sqljdbc41.jar
根據項目在Netbeans for myProject
選項卡,我有:
在庫文件夾
--> sqljdbc41.jar which is pointing to src/myProject/Microsoft/sqljdbc41.jar under Project Properties --> Library --> Compile tab
在服務選項卡我甚至做了如下:
根據數據庫樹
--> Drivers --> Microsoft SQL Server 2012 registered connection to verify connection in my project.
所以我失去了什麼或者沒做是否正確?我不知道我能,還是需要以某種方式明確提到Ant腳本類路徑?這是我用ANT所以它仍然是一個學習的過程對我來說是第一次!
下面是我用我的build.xml文件Ant腳本:
<fx:deploy width="${javafx.run.width}" height="${javafx.run.height}"
nativeBundles="EXE"
outdir="${basedir}/${dist.dir}" outfile="${application.title}">
<fx:application name="${application.title}"
version="1.0.0"
mainClass="${javafx.main.class}"
preloaderClass="firstPreloader.FirstPreloader"/>
<fx:permissions elevated="true"/>
<fx:preferences shortcut="true" menu="true" install="true"/>
<fx:resources>
<fx:fileset id="preloader-files" requiredFor="preloader" dir="${basedir}/dist/lib" includes="FirstPreloader.jar"/>
<fx:fileset dir="${basedir}/${dist.dir}" includes="*.jar"/>
<fx:fileset dir="${basedir}/${dist.dir}" includes="lib/*.jar"/>
<fx:fileset os="windows" type="license" includes="license.rtf" dir="${basedir}/src/myProject/package" />
<fx:fileset os="windows" type="data" includes="config.properties" dir="${basedir}" />
<fx:fileset dir="build" type="native" os="windows" arch="x64" includes="native-libs-win-x86_64.jar"/>
</fx:resources>
<fx:info title="${application.title}"
vendor="${application.vendor}">
<fx:icon href="./package/windows/myProject.ico"/>
<fx:splash href="./package/windows/myProject_Splash.png"/>
</fx:info>
</fx:deploy>
我承認,我是救命稻草,現在抓了,我仍沒有成功,我甚至做了以下事情:
在清單文件中我有:
清單-版本:1.0 類路徑:C:\用戶\馬特\文件\的NetBeansProjects \ myProject的\ SRC \ myProject的\微軟\ sqljdbc41.jar X-COMMENT:主類會自動生成添加
目標標籤和(FX部署)標籤我終於摸索出瞭如何使用(FX JAR)標籤之間夾着:
<fx:jar destfile="${basedir}/${dist.dir}/myProject.jar">
<fx:application name="myProject Application" mainClass="myProject.myProject"/>
<fx:resources>
<fx:fileset dir="${basedir}/${dist.dir}" includes="lib/*.jar"/>
</fx:resources>
<fx:fileset dir="build/classes"/>
<manifest>
<attribute name="Class-Path" value="${basedir}sqljdbc41.jar"/>
</manifest>
</fx:jar>
但我還是像以前一樣得到同樣的異常!那麼,我該如何做到這一點?請幫助!