我正在尝试在 windows-7 上制作一个简单的 Java 应用程序,它可以从 mysql 进行数据库备份。我需要 mysql 基本路径。我尝试使用 JPQL
EntityManagerFactory emf = Persistence.createEntityManagerFactory("BackupRestoreMysqlDatabasePU");
EntityManager em = emf.createEntityManager();
String path = em.createQuery("SELECT @@basedir").getSingleResult().toString();
System.out.println("My Database Path::" + path);
当我运行它时,显示以下错误:
Exception in thread "main" java.lang.IllegalArgumentException: An exception occurred while creating a query in EntityManager:
Exception Description: Syntax error parsing [SELECT @@basedir].
[16, 16] A select statement must have a FROM clause.
[7, 16] The identification variable '@@basedir' is not following the rules for a Java identifier.
at org.eclipse.persistence.internal.jpa.EntityManagerImpl.createQuery(EntityManagerImpl.java:1585)
atJava Result: 1
请帮我。