在persistence.xml JPA配置文件中,您可以使用如下行:
<persistence-unit name="com.nz_war_1.0-SNAPSHOTPU" transaction-type="JTA">
Run Code Online (Sandbox Code Playgroud)
或有时:
<persistence-unit name="com.nz_war_1.0-SNAPSHOTPU" transaction-type=”RESOURCE_LOCAL”>
Run Code Online (Sandbox Code Playgroud)
我的问题是:
transaction-type="JTA"
和之间有什么区别transaction-type=”RESOURCE_LOCAL”
?
我还注意到一些缺少事务类型的persistence.xml文件.这是对的吗?
我需要修改文件/etc/httpd/conf.d/phpMyAdmin.conf
以允许远程用户(不仅是localhost)登录
# phpMyAdmin - Web based MySQL browser written in php
#
# Allows only localhost by default
#
# But allowing phpMyAdmin to anyone other than localhost should be considered
# dangerous unless properly secured by SSL
Alias /phpMyAdmin /usr/share/phpMyAdmin
Alias /phpmyadmin /usr/share/phpMyAdmin
<Directory /usr/share/phpMyAdmin/>
<IfModule mod_authz_core.c>
# Apache 2.4
<RequireAny>
Require ip 127.0.0.1
Require ip ::1
</RequireAny>
</IfModule>
<IfModule !mod_authz_core.c>
# Apache 2.2
Order Deny,Allow
Deny from All
Allow from 127.0.0.1
Allow from ::1
</IfModule>
</Directory> …
Run Code Online (Sandbox Code Playgroud) 我开始学习POSIX计时器,所以我开始做一些练习,但我立即遇到了编译器的一些问题.在编译这段代码时,我收到一些关于像CLOCK_MONOTONIC这样的宏的奇怪消息.这些在各种库中定义,如time.h等,但编译器给出了错误,好像它们没有定义.
这很奇怪,因为我使用的是Fedora 16,而且我的一些Ubuntu朋友得到的编译错误比我少:-O
我正在编译 gcc -O0 -g3 -Wall -c -fmessage-length=0 -std=c99 -lrt
我得到的错误:
struct sigevent sigeventStruct
给出:
storage size of ‘sigeventStruct’ isn’t known
unused variable ‘sigeventStruct’ [-Wunused-variable]
Type 'sigevent' could not be resolved
unknown type name ‘sigevent’
Run Code Online (Sandbox Code Playgroud)sigeventStruct.sigev_notify = SIGEV_SIGNAL
给出:
‘SIGEV_SIGNAL’ undeclared (first use in this function)
request for member ‘sigev_notify’ in something not a structure or union
Field 'sigev_notify' could not be resolved
Run Code Online (Sandbox Code Playgroud)if(timer_create(CLOCK_MONOTONIC, sigeventStruct, numero1) == -1)
给出:
implicit declaration of function ‘timer_create’ [-Wimplicit-function- …
Run Code Online (Sandbox Code Playgroud)在LyX中有以下siunitx表代码,对于每次出现的\ toprule和\ midrule,我都会收到一条错误消息:
错误消息顶行末尾的控制序列从未\ def'ed.如果你拼错了它(例如,
\hobx'), type
我'和正确的拼写(例如,'I\hbox').否则只是继续,我会忘记任何未定义的.
我在序言中正确导入了siunitx.TexLive版本:2012.10.20121205_r28449.fc18
乳胶代码:
\centering
\sisetup{output-decimal-marker={,}}
\begin{tabular}{ccS}
\toprule
{Dimensione finestra} & {Perdita} & {Tempo}\\
{} & {} & {(secondi)}\\
\midrule
10 & 0$\%$ & 121\\
\midrule
10 & 10$\%$ & 127\\
\midrule
10 & 20$\%$ & 176\\
\midrule
10 & 30$\%$ & 257\\
\midrule
10 & 40$\%$ & 442\\
\midrule
10 & 50$\%$ & 780\\
\midrule
10 & 60$\%$ & 1226\\
\midrule
10 & 70$\%$ & 1469\\
\midrule
10 & 80$\%$ & 1904 \\ …
Run Code Online (Sandbox Code Playgroud) 我正在遵循GIT的官方指南,实际上我在2.2.6段"承诺你的改变"以前,在第1.5.1节"身份"时被要求输入一个像
git config --global user.name "John Doe"
Run Code Online (Sandbox Code Playgroud)
我错过了--global选项,因为我不需要它.现在每次我做git提交,我都会获得
$git commit
*** Please tell me who you are.
Run
git config --global user.email "you@example.com"
git config --global user.name "Your Name"
to set your account's default identity.
Omit --global to set the identity only in this repository.
Run Code Online (Sandbox Code Playgroud)
但我不想输入--global选项,是否存在另一种方式?
我完成了http://arquillian.org/guides/testing_java_persistence/上的JPA教程,但是当我尝试以JUnit运行测试(在指南的"运行GlassFish上的测试"部分)时,我在Eclipse中获取了以下消息:安慰:
java.lang.RuntimeException: Could not create new instance of class org.jboss.arquillian.test.impl.EventTestRunnerAdaptor
at org.jboss.arquillian.test.spi.SecurityActions.newInstance(SecurityActions.java:160)
at org.jboss.arquillian.test.spi.SecurityActions.newInstance(SecurityActions.java:111)
at org.jboss.arquillian.test.spi.SecurityActions.newInstance(SecurityActions.java:97)
at org.jboss.arquillian.test.spi.TestRunnerAdaptorBuilder.build(TestRunnerAdaptorBuilder.java:52)
at org.jboss.arquillian.junit.Arquillian.run(Arquillian.java:93)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
at org.jboss.arquillian.test.spi.SecurityActions.newInstance(SecurityActions.java:156)
... 10 more
Caused by: org.jboss.arquillian.container.impl.ContainerCreationException: Could not create Container glassfish-embedded
at org.jboss.arquillian.container.impl.LocalContainerRegistry.create(LocalContainerRegistry.java:85)
at org.jboss.arquillian.container.impl.client.container.ContainerRegistryCreator.createRegistry(ContainerRegistryCreator.java:76)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)
at org.jboss.arquillian.core.impl.EventContextImpl.invokeObservers(EventContextImpl.java:99)
at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:81)
at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:135) …
Run Code Online (Sandbox Code Playgroud) 我正在https://www.primefaces.org/showcase/ui/overlay/dialog/loginDemo.xhtml上测试PrimeFaces示例.我在Eclipse Dyamic web项目中正确导入了PrimeFaces和JSF 2.1,但是在启动网页时遇到以下错误(使用Tomcat):
javax.faces.view.facelets.TagException: /login.xhtml at line 30 and column 36 <f:facet> Tag Library supports namespace: http://java.sun.com/jsf/html, but no tag was defined for name: facet
org.apache.myfaces.view.facelets.compiler.CompilationManager.pushTag(CompilationManager.java:282)
org.apache.myfaces.view.facelets.compiler.SAXCompiler$CompilationHandler.startElement(SAXCompiler.java:250)
com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(AbstractSAXParser.java:506)
com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.startElement(XMLDTDValidator.java:745)
com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(XMLNSDocumentScannerImpl.java:376)
com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2717)
com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:607)
com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:116)
com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:489)
com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:835)
com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:764)
com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:123)
com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1210)
com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:568)
com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl.parse(SAXParserImpl.java:302)
javax.xml.parsers.SAXParser.parse(SAXParser.java:195)
org.apache.myfaces.view.facelets.compiler.SAXCompiler.doCompile(SAXCompiler.java:739)
org.apache.myfaces.view.facelets.compiler.Compiler.compile(Compiler.java:128)
org.apache.myfaces.view.facelets.impl.DefaultFaceletFactory._createFacelet(DefaultFaceletFactory.java:300)
org.apache.myfaces.view.facelets.impl.DefaultFaceletFactory.access$000(DefaultFaceletFactory.java:53)
org.apache.myfaces.view.facelets.impl.DefaultFaceletFactory$1.newInstance(DefaultFaceletFactory.java:114)
org.apache.myfaces.view.facelets.impl.DefaultFaceletFactory$1.newInstance(DefaultFaceletFactory.java:111)
org.apache.myfaces.view.facelets.impl.FaceletCacheImpl.getFacelet(FaceletCacheImpl.java:83)
org.apache.myfaces.view.facelets.impl.FaceletCacheImpl.getFacelet(FaceletCacheImpl.java:50)
org.apache.myfaces.view.facelets.impl.DefaultFaceletFactory.getFacelet(DefaultFaceletFactory.java:199)
org.apache.myfaces.view.facelets.impl.DefaultFaceletFactory.getFacelet(DefaultFaceletFactory.java:182)
org.apache.myfaces.view.facelets.FaceletViewDeclarationLanguage._getFacelet(FaceletViewDeclarationLanguage.java:2622)
org.apache.myfaces.view.facelets.FaceletViewDeclarationLanguage.buildView(FaceletViewDeclarationLanguage.java:452)
org.apache.myfaces.lifecycle.RenderResponseExecutor.execute(RenderResponseExecutor.java:78)
org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:241)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:199)
note The full stack trace of the root cause is available in the Apache Tomcat/7.0.21 logs.
Run Code Online (Sandbox Code Playgroud)
LoginBean.java包含:
package classi;
import java.awt.event.ActionEvent; …
Run Code Online (Sandbox Code Playgroud) 我跟着
https://glassfish.java.net/javaee5/persistence/persistence-example.html
在Java SE环境中测试JPA.在Eclipse中,我:
我成功导入了zip文件(Client.java Customer.java Order.java)中的树Java类,并修改了persistence.xml文件以满足我的需要.但是在尝试执行main时我得到以下错误.
[EL Info]: 2013-10-18 17:37:54.749--ServerSession(263489307)--EclipseLink, version: Eclipse Persistence Services - 2.5.1.v20130918-f2b9fc5
[EL Info]: connection: 2013-10-18 17:37:55.34--ServerSession(263489307)--file:/home/caterpillar/workspace/JPA_Java_SE/build/classes/_JPA_Java_SE login successful
[EL Warning]: metamodel: 2013-10-18 17:37:55.359--The collection of metamodel types is empty. Model classes may not have been found during entity search for Java SE and some Java EE container managed persistence units. Please verify that your entity classes are referenced in persistence.xml using either <class> elements or a global <exclude-unlisted-classes>false</exclude-unlisted-classes> …
Run Code Online (Sandbox Code Playgroud) 在Java/MariaDb中使用preparedStatement,如下面的函数所示
public ArrayList<String> findPath(String roomName) throws SQLException, IOException, InstantiationException, IllegalAccessException, ClassNotFoundException
{
ArrayList<String> path = new ArrayList<String>();
connection = getConnection();
String queryPattern = "SELECT `Livello_1`, `Livello_2`, `Livello_3`, `Livello_4` FROM Camera WHERE Camera.Nome = '?'";
PreparedStatement queryStatement = connection.prepareStatement(queryPattern);
queryStatement.setString(1, roomName);
ResultSet rs = queryStatement.executeQuery();
if(rs.next())
{
for(int i = 0; i < 3; i++)
{
path.add(rs.getString(i));
}
}
return path;
}
Run Code Online (Sandbox Code Playgroud)
我收到错误消息:
java.sql.SQLException:参数索引超出范围(1>参数个数,为0).
并且错误行号指向行
queryStatement.setString(1, roomName);
Run Code Online (Sandbox Code Playgroud) 我正在使用JSF,PrimeFaces,JPA开发动态Web项目(Java EE),并在Tomcat 7上运行。该项目的开发基于http://www.simtay.com/simple-crud-web-application-with- jsf-2-1-primefaces-3-5-maven-and-jpa /
现在,我正在开发该软件的JPA部分。过去,当我在Java SE中开发一些小东西(作为练习)时,我曾经使用以下数据库属性:
jdbc.drivers=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=utf8
jdbc.username=root
jdbc.password=password
Run Code Online (Sandbox Code Playgroud)
但是现在我正在Java EE上学习JPA。
在“ Pro JPA 2 Mastering the Java trade Persistance API”一书的第3章,“打包”中,您可以阅读:
在Java EE环境中,可以省略persistence.xml文件中Java SE所需的许多属性。在清单3-32中,您可以看到清单2-11中的persistence.xml文件已转换为部署为Java EE应用程序的一部分。现在,我们声明实体管理器应使用数据源名称“ jdbc / EmployeeDS”,而不是用于创建连接的JDBC属性。如果将数据源定义为在应用程序名称空间中可用,而不是在本地组件命名上下文中可用,则我们可以改用数据源名称“ java:app / jdbc / EmployeeDS”。事务类型属性也已删除,以允许持久性单元默认为JTA。应用程序服务器将自动查找实体类,因此,甚至类列表也已删除。此示例表示理想的最低Java EE配置。因为使用此持久性单元的业务逻辑是在无状态会话Bean中实现的,所以persistence.xml文件通常位于相应的EJB JAR的META-INF目录中。
清单3-32 在Java EE中定义持久性单元
<persistence>
<persistence-unit name="EmployeeService">
<jta-data-source>jdbc/EmployeeDS</jta-data-source>
</persistence-unit>
</persistence>
Run Code Online (Sandbox Code Playgroud)
清单2-11 persistence.xml文件中的元素
<persistence>
<persistence-unit name="EmployeeService" transaction-type="RESOURCE_LOCAL">
<class>examples.model.Employee</class>
<properties>
<property name="javax.persistence.jdbc.driver" value="org.apache.derby.jdbc.ClientDriver"/>
<property name="javax.persistence.jdbc.url" value="jdbc:derby://localhost:1527 EmpServDB;create=true"/>
<property name="javax.persistence.jdbc.user" value="APP"/>
<property name="javax.persistence.jdbc.password" value="APP"/>
</properties>
</persistence-unit>
</persistence>
Run Code Online (Sandbox Code Playgroud)
我的问题是:如何使用我在文章顶部输入的属性来适应Java EE环境中的通用persistence.xml文件以连接到MySQL / JDBC数据库?