miércoles, 22 de diciembre de 2010

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

ORA-28009: connection as SYS should be as SYSDBA or SYSOPER
Symtompts of the Problem:
---------------------------
Whenever you try to conenct to database by providing SYS user name and password it retuens error.
ORA-28009: connection as SYS should be as SYSDBA or SYSOPER

Cause of The Problem:
--------------------
This is because of the parameter O7_DICTIONARY_ACCESSIBILITY settings to FALSE.

Access to dictionary objects is restricted to the users with the system privileges SYSDBA and SYSOPER. Connecting as SYSDBA gives a user unrestricted privileges to perform any operation on a database or the objects within a database. Data dictionary objects is under SYS schema and is protected by O7_DICTIONARY_ACCESSIBILITY to FALSE settings.

Workaround Example:
---------------------
1)Try to connect by user sys without sysdba privilege.

SQL> conn sys/a
ERROR:
ORA-28009: connection as SYS should be as SYSDBA or SYSOPER
Warning: You are no longer connected to ORACLE.

2)Connect as sysdba and change O7_DICTIONARY_ACCESSIBILITY
SQL> conn / as sysdba
Connected.

SQL> SHOW PARAMETER O7_DICTIONARY_ACCESSIBILITY
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
O7_DICTIONARY_ACCESSIBILITY boolean FALSE

SQL> ALTER SYSTEM SET O7_DICTIONARY_ACCESSIBILITY=TRUE scope=spfile;
System altered.

3)Since O7_DICTIONARY_ACCESSIBILITY is static parameter restart is necessary.

SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.

SQL> startup
ORACLE instance started.
Total System Global Area 167772160 bytes
Fixed Size 2019288 bytes
Variable Size 109051944 bytes
Database Buffers 50331648 bytes
Redo Buffers 6369280 bytes
Database mounted.
Database opened.

4)Now connect as sys with only password.

SQL> conn sys/a
Connected.

SQL> show parameter O7_DICTIONARY_ACCESSIBILITY
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
O7_DICTIONARY_ACCESSIBILITY boolean TRUE

5)Though you are SYS user but you have not currently have SYSDBA privilege. So, you can't do SYSDBA privilege tasks.

SQL> shutdown immediate;
ORA-01031: insufficient privileges

SQL> show user
USER is "SYS"



Caution:
-----------
Oracle Strongly recommends not to use O7_DICTIONARY_ACCESSIBILITY to TRUE.

fuente: http://arjudba.blogspot.com/2008/05/ora-28009-connection-as-sys-should-be.html

sábado, 18 de diciembre de 2010

Accediendo a un sitio HTTP/HTTPS desde Java

Un ejemplo:

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;

public class Main {
public static void main(String[] args)
throws MalformedURLException, IOException {
URL url = new URL("http://www.nic.cl");
URLConnection con = url.openConnection();

BufferedReader in = new BufferedReader(
new InputStreamReader(con.getInputStream()));

String linea;
while ((linea = in.readLine()) != null) {
System.out.println(linea);
}
}
}

La explicación de que hace este codigo se encuentra en este link:
http://lefunes.wordpress.com/2008/02/14/accediendo-a-un-sitio-httphttps-desde-java/

Ejemplo para HTTPURLConnection

sábado, 11 de diciembre de 2010

miércoles, 8 de diciembre de 2010

martes, 7 de diciembre de 2010