如何使用 java 代码登录 Oracle 11g 中的“xe"连接? [英] How do I login to 'xe' connection in Oracle 11g with java code?

查看:21
本文介绍了如何使用 java 代码登录 Oracle 11g 中的“xe"连接?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想编写只执行此操作的 Java 代码:

I want to make java code that does only this:

登录到 Oracle 11g 数据库中的xe"连接.就这样.怎么办呢?

Login to the 'xe' connection in Oracle 11g database. That's all. How can do it ?

是的,我正在使用 JDBC,但无法登录到该连接.对于 xe 或系统连接.那为什么我不能登录到那个连接?

yes, i was using JDBC, but unable to login to that connection. My url is jdbc:oracle:thin:@//localhost:1521/xe, username = sys and password = 123456 for the xe or sys connection. Then why can't i login to that connection ?

非常抱歉,我忘了补充,除了第一个错误,我还看到了另一个错误,即

I am very sorry, I forgot to add that I see another error besides the 1st one, i.e.

SQLException: ORA-28009: connection as SYS should be as SYSDBA or SYSOPER

后面跟着-

Exception in thread "main" java.lang.NullPointerException

推荐答案

如果你想以SYS身份连接,你必须使用sys as sysdba

If you want to connect as SYS you have to use sys as sysdba

所以在你的java代码中尝试像下面的代码

So in your java code try like the following code

    String url = "jdbc:oracle:thin:@//localhost:1521:xe";
    String username = "sys as sysdba";
    String password = "123456";
Connection connection= DriverManager.getConnection(url, username, password);

问候

这篇关于如何使用 java 代码登录 Oracle 11g 中的“xe"连接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆