简体   繁体   English

Oracle Express 18c 从 Java jdbc 应用程序登录

[英]Oracle Express 18c log on from Java jdbc application

new Oracle Express user here,新的 Oracle Express 用户在这里,

I did the db install w/o problems in my Win 64 environment, used sqlplus from terminal to create user and grant him roles and privileges, and finally this user works fine with the local db from Oracle SQLcl utility - tables, queries etc.我在我的 Win 64 环境中安装了没有问题的数据库,使用终端中的 sqlplus 创建用户并授予他角色和权限,最后这个用户可以很好地使用来自 Oracle SQLcl 实用程序的本地数据库 - 表,查询等。

The problem comes when I try to use the provided boilerplate code from Oracle for Java.当我尝试使用 Oracle for Java 提供的样板代码时,问题就出现了。 In Eclipse, in new project, with added jdbc8 jars the tested in SQLcl user creadentials are rejected with exception: java.sql.SQLException: ORA-01045: user C##DBUSER lacks CREATE SESSION privilege;在 Eclipse 中,在新项目中,添加了 jdbc8 jar,在 SQLcl 用户凭据中测试的测试被拒绝,异常:java.sql.SQLException:ORA-01045:用户 C##DBUSER 缺少 CREATE SESSION 权限; logon denied.登录被拒绝。

Here is the Oracle boiler code used, with my local details :这是使用的 Oracle 锅炉代码,以及我的本地详细信息:

  OracleDataSource ods = new OracleDataSource();
  ods.setURL("jdbc:oracle:thin:@//localhost:1521/XEPDB1"); 
  ods.setUser("c##dbUser"); 
  ods.setPassword("dbUserPassowrd"); 
  Connection conn = ods.getConnection();

  PreparedStatement stmt = conn.prepareStatement("SELECT 'Hello World!' FROM dual");
  ResultSet rslt = stmt.executeQuery();
  while (rslt.next()) {
    System.out.println(rslt.getString(1));
  }

Would appreciate your help, thanks!感谢您的帮助,谢谢!

正确的连接字符串必须是:“jdbc:oracle:thin:@//localhost:1521/XE”,以说明创建用户并授予权限的数据库名称。

As Oracle says:正如甲骨文所说:

user C##DBUSER lacks CREATE SESSION privilege;用户 C##DBUSER 缺少 CREATE SESSION 权限; logon denied.登录被拒绝。

Connect to the Oracle database as a privileged user (such as SYS) and以特权用户(如 SYS)身份连接到 Oracle 数据库并

grant create session to c##dbuser;

(or whichever user name it really is). (或它确实是哪个用户名)。

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

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