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

查看:116
本文介绍了如何使用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或sys连接,我的URL是jdbc:oracle:thin:@//localhost:1521/xeusername = syspassword = 123456.那我为什么不能登录该连接?

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天全站免登陆