web與sql伺服器搭建
㈠ 如何在web中使用activiti和sql server
一、按照如下方式新建一個web工程
之所以要用maven,主要是為了解決各種依賴項的問題,用maven來管理依賴項還是很方便的。
用Eclipse創建Maven結構的web項目的時候選擇了Artifact
Id為maven-artchetype-webapp,由於這個catalog比較老,用的servlet還是2.3的,而一般現在都是用3.0,在
Project Facets裡面修改Dynamic web mole為3.0的時候就會出現Cannot change version of
project facet Dynamic web mole to 3.0,如圖:
解決這個問題的步驟如下:
1. 把Servlet改成3.0,打開項目的web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
id="schele-console" version="3.0">
2. 修改項目的設置,在Navigator下打開項目.settings目錄下的org.eclipse.jdt.core.prefs
把1.5改成1.8
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.source=1.8
3. 打開org.eclipse.wst.common.project.facet.core.xml
把java改為1.8, 把jst.web改為3.0;
<?xml version="1.0" encoding="UTF-8"?>
<faceted-project>
<fixed facet="wst.jsdt.web"/>
<installed facet="jst.web" version="3.0"/>
<installed facet="wst.jsdt.web" version="1.0"/>
<installed facet="java" version="1.8"/>
</faceted-project>
二、解決報錯The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Path
可以使用如下步驟來解決。
1、右擊web工程-》屬性或Build Path-》Java Build Path->Libraries-> Add Libray...->Server Runtime -》Tomcat Server
2、切換到Java Build Path界面中的Orader and Export,選擇Tomcat。
三、修改項目的pom.xml文件,添加activiti相關依賴項
相關依賴項如下:
<dependency>
<groupId>org.activiti</groupId>
<artifactId>activiti-engine</artifactId>
<version>${activiti-version}</version>
</dependency>
<dependency>
<groupId>org.activiti</groupId>
<artifactId>activiti-spring</artifactId>
<version>${activiti-version}</version>
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
<version>2.4.3</version>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>1.3.168</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.6</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-jdk14</artifactId>
<version>1.7.6</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
</dependency>
其中activiti-version的定義如下:
<properties>
<activiti-version>5.18.0</activiti-version>
</properties>
其實這些內容我都是從Activiti工程的pom文件中拷貝過來的。
四、添加activiti需要的配置文件
在activiti的userguide(http://activiti.org/userguide/index.html#_configuration )中有說。
如果我們使用如下語句來創建一個流程引擎實例
ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine()
那麼實際上他是到該項目的classpath路徑下去找一個名為
activiti.cfg.xml的配置文件,然後根據該配置文件的設置,通過spring的方式來創建一個processEngine。而且是去找其中
的那個名字是default的processEngine。
所以我們可以在該項目的src/main/resources 目錄下創建一個名為 activiti.cfg.xml的文件,然後將如下內容復制進去。
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean id="processEngineConfiguration" class="org.activiti.engine.impl.cfg.">
</bean>
</beans>
五、創建sql server資料庫
通過sql server management studio 創建一個資料庫,比如名字叫做 activiti
六、在maven中添加sql server jdbc依賴項
在maven倉庫中是沒有sql server 的jdbc jar包的,可以按照如下步驟操作
Download the JDBC driver for Microsoft SQL Server
Visit the MSDN site for SQL Server and download the latest version of the JDBC driver for your operating system.
Unzip the package
Open a command prompt and switch into the expanded directory where the jar file is located.
Execute the following command. Be sure to modify the jar file name and version as necessary:
1
mvn install:install-file -Dfile=sqljdbc4.jar -Dpackaging=jar -DgroupId=com.microsoft.sqlserver -DartifactId=sqljdbc4 -Dversion=4.0
You should see something similar to this:
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-install-plugin:2.3.1:install-file (default-cli) @ standalone-pom ---
[INFO] Installing /Users/claude/installers/JDBC/sqljdbc_4.0/enu/sqljdbc4.jar to /Users/claude/.m2/repository/com/microsoft/sqlserver/sqljdbc4/4.0/sqljdbc4-4.0.jar
[INFO] Installing /var/folders/c6//T/mvninstall1874482299687761721.pom to /Users/claude/.m2/repository/com/microsoft/sqlserver/sqljdbc4/4.0/sqljdbc4-4.0.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.208s
[INFO] Finished at: Tue Mar 13 14:07:31 EDT 2012
[INFO] Final Memory: 3M/81M
[INFO] ------------------------------------------------------------------------
Modify your POM
Include the new dependency by modifying your project』s pom.xml. Add the following dependency:
1
2
3
4
5
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>sqljdbc4</artifactId>
<version>4.0</version>
</dependency>
Save the pom.xml file and build the project to make sure no errors exist.
七、讓activiti連接sql server資料庫
修改第四節中的activiti.cfg.xml文件,將 processEngineConfiguration的內容改成下文這樣:
<bean id="processEngineConfiguration" class="org.activiti.engine.impl.cfg.">
<property name="databaseSchemaUpdate" value="true"/>
<property name="jdbcUrl" value="jdbc:sqlserver://localhost:1433;databaseName=activiti2 " />
<property name="jdbcDriver" value="com.microsoft.sqlserver.jdbc.SQLServerDriver" />
<property name="jdbcUsername" value="sa" />
<property name="jdbcPassword" value="sa123" />
</bean>
八、在代碼中使用activiti的api
ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
if(processEngine != null)
{
out.println("<h1> Hello !" + processEngine.getName() + "</h1>");
IdentityService identityService = processEngine.getIdentityService();
List<String> keys = identityService.getUserInfoKeys("Kermit");
for(String key: keys)
{
out.println(String.format("<h1> key = %s, value = %s </h1>", key, identityService.getUserInfo("Kermit", key)));
}
}
以上在調用 ProcessEngines.getDefaultProcessEngine(); 的時候,實際上背後就會去調用搜索classPath目錄下的activiti.cfg.xml文件,然後通過其中的配置來創建processEngine對象。
九、在eclipse中調試activiti項目
在eclipse中調試web項目,其實他是把相關的資料生成到如下路徑:
<eclipse workspace dir>\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\MavenWeb
如果發現某項配置修改之後,調試的時候沒有生效,那可以試著clean一下, Project ->clean...,然後重新生成即可。
㈡ 我想在WIN7上做一個WEB(網站)伺服器,運行的是ASP程序和MSSQL資料庫,請問怎麼做
1.安裝IIS (部分版本的win7不含iis)
開始-控制面板-程序-打開或關閉windows功能
勾選internet信息服務,確保列表樹中的asp被勾上。
2.配置IIS7
IIS7 在安裝了上述組件後,控制面板-系統和安全-管理工具-Internet信息服務(慎敗IIS)
管理工具,打開運行。明態雙擊內頁中的ASP,即顯示ASP的設置內容,"寬槐顫,然後在"Behavior(行為)"組中將"Enable Parent Paths(啟用父路徑)"設置為True即可。配置默認網站,填寫 物理路徑、應用程序池,點OK即可。
順便說一下:
我是win7 64位系統,之前在搭建asp+access時發現要進行如下設置:
應用程序池,高級設置-->允許32位應用程序 True
否則無法連接資料庫。
㈢ web伺服器是否一定要安裝SQL
問題1:要調用資料庫當然要有相應的資料庫伺服器來執行你應用程序發過來的sql語句,然後把執行的結果返回給應用程序了。所以肯定是要安裝資料庫伺服器的,我說的是不用遠程資料庫的話。
問題2:用SqlServer舉例,安裝一個sql server實例後春茄,就會有一個mdf文件,這個mdf文件里存有該資料庫實例的大坦豎部門的信息,以後新扒信察建的資料庫都會存在該文件里,所以新建一個資料庫不會再產生mdf文件,只會在原來的mdf追加數據。
㈣ 如何在web中建立 自己的sql資料庫
資料庫種類很多,有關系型數吵早埋據庫、非關系型資料庫
企業升螞開發中用的較多的是三種關系型資料庫:MySQL、MS SQL SERVER、Oracle。
中小企業網站中可以使用單文件資料庫:Access、Sqlite等
前三種睜察是需要單獨安裝到伺服器中,後二者都是單個文件,有專門的軟體生成。
㈤ 僅僅使用sql而不需要其他高級語言能搭建一個網站嗎
sql是一種資料庫查詢語言,其它高級語言只是派殲用來編程實現某種功能軟體,或是某些軟體的腳本。
僅僅使用sql語言是不能實現一個網站的功能,要實現網站功能也就是要實現WEB伺服器。
Web伺服器一般指網站伺服器,是指駐留於網際網路上某種類型塵並沖計算機的程序,可以向瀏覽器等Web客戶端提供文檔,也可以放置網站文件,讓全世界瀏覽;可以放置數據文件,讓全世界下載。目蔽滾前最主流的三個Web伺服器是Apache、 Nginx 、IIS。
而sql語言是sql伺服器的查詢語言,sql伺服器主要是為web伺服器服務的。
㈥ WEB加SQL WIN2003需要搭建什麼伺服器軟體
IIS就夠了。
win2003自帶。
㈦ 如何搭建資料庫伺服器和web伺服器
分別說明一下web伺服器和資料庫伺服器,以下就是兩者的區別:
1、web伺服器
web伺服器一般指網站伺服器,是指駐留於網際網路上某種類型計算機的程序,可以向瀏覽器等web客戶端提供文檔。
web伺服器可以放置網站文件,讓全世界瀏覽;可以放置數據文件,讓全世界下載。
目前最主流的三個web伺服器是:apache、nginx、iis。
2、資料庫伺服器
運行在區域網中的一台或多台計算機和資料庫管理系統軟體共同構成了資料庫伺服器,資料庫伺服器為客戶應用提供服務,這些服務是查詢、更新、事務管理、索引、高速緩存、查詢優化、安全及多用戶存取控制等。
㈧ web伺服器和資料庫伺服器怎麼連接
如果兩個服務是不同的伺服器,資料庫伺服器需要開啟對應的外網訪問埠並進行設置。如果是在同一個伺服器上,使用資料庫連接程序、賬號密碼即可連接。
㈨ 怎樣把sql資料庫和web伺服器連接起來
public Connection getNewConnection(){
Connection con=null;
try {
Class.forName("com.mysql.jdbc.Driver");
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
con=DriverManager.getConnection("jdbc:mysql://localhost(或者你連的主機IP):3306/數歲知據庫乎纖消名稱","用戶名","密碼");
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return con;
}
這是一個連接豎檔mysql的例子
㈩ APP的本地伺服器如WEBSQL和資料庫伺服器MYSQL怎麼建立連接,能不能舉個詳細的例子
最簡單的理解哈(個人理解),昌檔伺服器,顧名耐冊亂思義,就是放服務的地方,就是發布各種服務的主機,比如說網站呀之類的,如Web伺服器。資料庫的話,簡單說也就是放數據的地方,管理數據的一個系統。
舉個例子哈,比如你在伺服器上發布了個網站(一般都是動態的啦),這網站是有數據吧,數據就是從資料庫讀出來,這資料庫可以和這些網站放在同一主機,也可以放在另外一台主機。
如果把網站放一個主機,把資料庫放一個主機,這樣的話,放網站的主機就叫Web伺服器,放資料庫的主機就叫資料庫伺服器。
不曉得你想要了解到啥程度,偶說的自我感覺非常非常非姿運常的淺,也不曉得說的對不對,你看一下就行了。。呵呵。。