简体   繁体   English

Glassfish容器管理的数据库位置

[英]Glassfish container managed database location

I have a glassfish container managed derby database that I can access using CRUD operations. 我有一个玻璃鱼容器管理的derby数据库,可以使用CRUD操作进行访问。 I would like to access my derby database directly through the asadmin tool to view the tables. 我想直接通过asadmin工具访问我的derby数据库以查看表。

However, I cannot find my database. 但是,我找不到数据库。

After researching this site i see that glassfish creates connection pools that connect only when required. 在研究了该站点之后,我发现glassfish创建了仅在需要时才进行连接的连接池。 I see that it is possible for me to create a connection pool but I don't even know where the database is. 我看到可以创建连接池,但是我什至不知道数据库在哪里。

Any advice is greatly appreciated. 任何意见是极大的赞赏。 I am new to JEE7 and learning from 'JEE7 for beginners' book. 我是JEE7的新手,正在学习“面向初学者的JEE7”书。

<persistence-unit name="chapter15PU" transaction-type="JTA">
    <jta-data-source>jdbc/__default</jta-data-source>
    <properties>
        <property name="javax.persistence.schema-generation.database.action" value="drop-and-    create"/>
        <property name="eclipselink.logging.level" value="INFO"/>
    </properties>
</persistence-unit>

To connect using derby ij command line tool use the following command: 要使用derby ij命令行工具进行连接,请使用以下命令:

connect 'jdbc:derby://localhost:1527/sun-appserv-samples';

'sun-appserv-samples' is the default Glassfish container managed db name. “ sun-appserv-samples”是默认的Glassfish容器托管的数据库名称。

As follows; 如下;

Oracle documentation on domain.xml file 关于domain.xml文件的Oracle文档

If you specify that you're database is to be container managed and you are using Glassfish, then all of the database properties can be found in the domain.xml file. 如果您指定数据库是由容器管理的,并且使用的是Glassfish,则可以在domain.xml文件中找到所有数据库属性。

For example, if you are using the default glassfish domain named domain1, then you must navigate to ..glassfish/domains/domain1 on you're file system. 例如,如果您使用的默认玻璃鱼域名为domain1,则必须在文件系统上导航至..glassfish / domains / domain1。 The domain.xml file can be found in the config folder. 您可以在config文件夹中找到domain.xml文件。

Here you will find the following information detailing all of you're database properties. 在这里,您会发现以下信息,详细介绍了所有数据库属性。

<property name="PortNumber" value="1527"></property>
<property name="Password" value="APP"></property>
<property name="User" value="APP"></property>
<property name="serverName" value="localhost"></property>
<property name="DatabaseName" value="sun-appserv-samples"></property>
<property name="connectionAttributes" value=";create=true"></property>

As you can see the default database name is sun-appserv-samples. 如您所见,默认数据库名称为sun-appserv-samples。

To connect to this database you must open the command tool ij which can be found in you're derby bin folder. 要连接到该数据库,必须打开命令工具ij,该工具可在derby bin文件夹中找到。 Then use the following command to connect to the database. 然后使用以下命令连接到数据库。

connect 'jdbc:derby://localhost:1527/sun-appserv-samples';

Note: You must have derby running and you're java web application deployed on Glassfish first. 注意:您必须运行derby,并且您是首先在Glassfish上部署的Java Web应用程序。

我不确定您是否可以直接访问内存中的derby数据库。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM