Home > database >  Tomcat connect GBase 8 a cluster
Tomcat connect GBase 8 a cluster

Time:04-24

Tomcat connect GBase 8 a cluster
1 install Tomcat configuration environment
Tomcat 1.1 introduction
Tomcat server is a free open source Web application server, belongs to a lightweight application server, in small and medium system and concurrent access to the user is not a lot of cases are commonly used, is the first selection of development and debugging JSP program,
Tomcat 1.2 installation
1.2.1 installed version
After download and install version, click next, and all the way direct installation is successful, configure the environment variables for
The installation directory for the TOMCAT_HOME you
The CATALINA_HOME your installation directory
This is the simplest installation method, and then go to the website to download the Administration Web Application, extract directly to the installation directory, can use directly,
1.2.2 decompressed version
Modify the bin \ startup. Bat file:
In front of the first line to join the following two lines -
SET the JAVA_HOME=(JDK directory)
SET the CATALINA_HOME=(after decompression in front of the Tomcat directory)
If you need to use shutdown. Bat shut down the server, also in accordance with the above to join the two lines,
So, run startup. Bat you can run the server, run the shutdown. The bat can shut down the server
1.3 setup Tomcat user name and password
Into the Tomcat directory: TOMCAT_HOME \ conf \ Tomcat - users XML
Modify tomcat - users. XML:
In & lt; Tomcat - users> Node add:
Tomcat 1.4 test
Run startup. Bat start the service
Open a web browser, enter the address: http://localhost:8080/
Single machine on the left side of the Tomcat Manager link, input set the user name and password
Data source configuration 2
XML files
2.1 configuration context.Enter the directory: TOMCAT_HOME \ conf, open context. The XML file, in & lt; Context> Add nodes:
//the name themselves, but must with the web. In the XML & lt; Res - ref - name> Consistent
Name="JDBC/GBaseDB
"Type="javax.mail. SQL. The DataSource"
Auth="Container"
//password to cluster the user password
Password="111111"
//driverClassName driver name
DriverClassName="com. Gbase. JDBC Driver"
MaxIdle="10"
MaxWait="10000"
InitialSize="10"
//username to cluster user
The username="gbase"
//url for the connection string, including the connection of the cluster nodes IP, port and need to access the database
Url="JDBC: gbase://192.168.5.6:5258/test", "
MaxActive="100"/& gt;

2.2 configuration web. XML file
Enter the directory: TOMCAT_HOME \ webapps \ \ WEB WEB applications - INF, open the WEB. The XML file, in & lt; Web - app> Add nodes:

The DB Connection
//res - ref - name must be with the web. In the XML & lt; Res - ref - name> Consistent
The JDBC/GBaseDB
Javax.mail. SQL. DataSource
Container

2.3 add database driver files
Copies the JDBC driver to the Tomcat lib directory

3 test connection
3.1 the new application under the TOMCAT_HOME \ webapps directory: GBaseTest
3.2 the TOMCAT_HOME \ webapps \ GBaseTest new directory under the WEB - INF
//must exist in the directory
3.3 in TOMCAT_HOME \ webapps \ GBaseTest \ WEB - under the INF new directory:
Class
Lib
//directory must exist, one in the class and can be null in the lib
3.4 in TOMCAT_HOME \ webapps \ GBaseTest \ WEB - newly built under the INF file:
Web.xml (i.e. steps of web 2.2, XML)
//advice from other webapps directory copy
3.5 under the TOMCAT_HOME \ webapps \ GBaseTest file: new connectTest. JSP
//new notepad file rename to
3.6 the connectTest. Add the following code in a JSP:
//the following Java code in blue highlight logo
<% @ page language="Java" import="javax.mail. SQL. *, Java, SQL *, javax.mail. Naming. *" contentType="text/HTML. GBK charset="% & gt;


GBase connection test & lt;/title> <br/></head> <br/><body> <br/>//& lt; % % markers for Java code & gt; <br/><% <br/>Try {<br/>The Context initCtx=new InitialContext (); <br/>//get the XML configuration file JDBC/GBaseDB associated data source object <br/>The DataSource ds1=(DataSource) initCtx <br/>Lookup (" Java: comp/env/JDBC/GBaseDB "); <br/>//access to the database connection object <br/>The Connection conn=an getConnection (); <br/>% & gt; <br/>//& lt; % % & gt; External to HTML code <br/><H1 style="color: red" & gt; The connection is successful & lt;/h1 & gt; <br/><% <br/>//will link back to the database connection pool <br/>conn.close(); <br/>% & gt; <br/><H1 style="color: red" & gt; Close the success & lt; H1 & gt; <br/><% <br/>} the catch (Exception e) {<br/>//output exception information <br/>Out.println (e. oString ()); <br/>} <br/>% & gt; <br/></body> <br/></html> <br/>3.7 open a web browser, type in the address bar: <br/>http://localhost:8080/GBaseTest/connectTest.jsp <br/>Test the connection was successful, <br/><br/> </div> <div class="th_page th_page_color"></div> <div class="umCopyright"> <p>Page link:<a href="/database/109154.html" target="_blank" style="color:#999">https//www.codepudding.com/database/109154.html</a></p> </div> <div class="detail-arr"> <div class="detail-arr-left">Prev:<a href='/database/109136.html'>O websocket client</a></div> <div class="detail-arr-right">Next:<a href='/database/109155.html'>Mysql data service automatically shut down</a></div> </div> </div> </div> </div> </div> <div class="container th_top"> <div class="row"> <div class="col-md-12"> <div class="hot-tags neitags"> <ul> <li><i class="iconfont icon-x-tags"></i> Tags:  </li> <a href='/e/tags/?tagname=Other+databases' target='_blank'>Other databases</a> </ul> </div> </div> </div> </div> <div class="container th_top"> <div class="row"> <div class="col-md-12"> <div class="xiangguan"> <ul class="msg msghead"> <li class="tbname">Related</li> </ul> <ul> </ul> </div> </div> </div> </div> <div class="container th_top"> <div class="row"> <div class="col-md-12"> <div class="flinks"> <ul> <li><i class="iconfont icon-x-tags"></i> Links:  </li> <li class="liflinks"><a target="_blank" href="/" title="CodePudding">CodePudding</a></li> </ul> </div> </div> </div> </div> <div class="footer"> <p><span style="font-size:16px;color:#666;font-weight: bold">About Us:</span>  <a href="https://www.codepudding.com/contact.html">Contact Us</a>      <a href="https://www.codepudding.com/service.html">Terms of Service</a>      <a href="https://www.codepudding.com/privacy.html"> Privacy Policy</a></p> <p class="foot_info">Copyright © 2010-2023,Powered By <a href="/" target="_blank">CodePudding</a> </p> </div> <script type="text/javascript" src="/skin/code/tianhu.js"></script> </body></html>