How to connect in java as SYS to Oracle?

Answers already there,

you are trying to connect as sys but the Server allows

either

sys as sysdba

or

sys as sysoper

just change user parameter as either one from above

user='sys as sysdba'

or

user='sys as sysoper'

This code works

String driverName = "oracle.jdbc.driver.OracleDriver";
Class.forName(driverName).newInstance();
String nameForConnect = "sys as sysdba";
String pass = "password";
String url = "jdbc:oracle:thin:@192.168.0.1:1521:ORCL";
Connection conn = DriverManager.getConnection(url, nameForConnect, pass);

try this :

import java.sql as jsql
import java.lang as lang
driver, url, user, passwd = (
"oracle.jdbc.driver.OracleDriver",
"jdbc:oracle:thin:@localhost:1234:xxx1",
"sys as sysdba",
"xxx1")
 lang.Class.forName(driver)
 c = jsql.DriverManager.getConnection(url,user,passwd)

If you have attempted to connect to the database like this: connect SYS/<password> you have used a syntax that is no longer valid (After Oracle 9i).

Instead try to connect as the following:

connect SYS/<password> as SYSDBA or connect SYS/<password> as SYSOPER