Friday, June 25, 2010

oracle related blogs

http://wiki.oracle.com/page/List+of+Oracle-related+blogs

The Q-quote mechanism

SQL> select q'(name LIKE '%DBMS_%%')'
2 from dual
3 /

Q'(NAMELIKE'%DBMS_%%
--------------------
name LIKE '%DBMS_%%'

SQL> select q'<'Data,' he said, 'Make it so.'>'
2 from dual
3 /

Q'<'DATA,'HESAID,'MAKEITSO.'>'
------------------------------
'Data,' he said, 'Make it so.'

SQL> select q'"name like '['"'
2 from dual
3 /

Q'"NAMELIKE'[
-------------
name like '['

regexp_instr

select * from emp where
regexp_instr(empnumber,'7566|7698')<>0

Saturday, June 19, 2010

Deploy Multiple Repositories in Oracle OBIEE

Deploy Multiple Repositories in Oracle OBIEE:

1. Open the NQSConfig.ini File in the following location

“E:\oracle\bise1\bi\server\Config “

2. Add multiple repositories under [REPOSITORY] like below

[ REPOSITORY]

ROADMAP = ROADMAP.rpd, DEFAULT;

ROADMAP_VASS = ROADMAP_VASS.rpd;

3. Open Microsoft ODBC Administrator. Move to “System DSN “ tab

4. Choose “ADD” Button to Add New Service. And on the pop up list choose Oracle BI server and proceed as in the below image.





And then Press “ Finish ”.

5. Go to the Location “E:\oracle\bise1\bidata\web\config”.

Copy “instanceconfig.xml “ File and Save as another file with Different Name.

Edit AnalyticsWeb as with the DSN you have created with Oracle BI

Server. Next to that add the following

And change the catalog path to the location you have copied the catalog root directory.

6. Go to Oracle BI Enterprise Manager , Application Tab.

Then press next to proceed to the next step.

Then press Next and Press Deploy .

7. Go to the Location “ E:\oracle\bise1\bi\oc4j_bi\j2ee\home\applications “ you will find the folder named “ Vass “ in that move to “E:\oracle\bise1\bi\oc4j_bi\j2ee\home\applications\analyticsvs\analytics”

And replace the “ res “ file with that of original analytics folder in application folder .

And move to “WEB-INF “ you will find a “web.xml” file .open the file in the notepad edit port no 9710 as 9711 specified in the “instanceconfig.xml “ file.

8. Go to command Prompt. Type the following

sc create sawsvc2 binpath= SEARCHFORMEPLEASE displayname= "Oracle BI Presentation Server 2"

9. open Registry editor through run Prompt. Go to “HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\sawsvc2”

Edit the Image Path Value "E:\oracle\bise1\bi\web\bin\sawserver.exe" /service /c E:\oracle\bise1\bidata\web\config\instanceconfigvs.xml

10. Go to Services and you should see Oracle BI Presentation Server 2 which when started should bring up your new Presentation Services.

Thursday, June 3, 2010

Mail Fetch

package mail;

import java.io.UnsupportedEncodingException;

import java.security.*;

import java.util.Properties;

import javax.mail.*;
import javax.mail.internet.MimeUtility;

public class GmailFetch {

public static void main(String[] args) throws Exception {

Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());
final String SSL_FACTORY = "javax.net.ssl.SSLSocketFactory";

// Get a Properties object
Properties props = System.getProperties();
props.setProperty("proxySet", "true");
//props.setProperty("http.ProxyHost", "192.168.0.6");
//props.setProperty("http.ProxyPort", "8181");

props.setProperty("mail.pop3.socketFactory.class", SSL_FACTORY);
props.setProperty("mail.pop3.socketFactory.fallback", "false");
props.setProperty("mail.pop3.port", "995");
props.setProperty("mail.pop3.socketFactory.port", "995");

Session session = Session.getDefaultInstance(props, null);


URLName urln =
new URLName("pop3", "pop.gmail.com", 995, null, "from@gmail.com",
"pass");
Store store = session.getStore(urln);
Folder inbox = null;
try {
store.connect();
inbox = store.getFolder("INBOX");
inbox.open(Folder.READ_ONLY);
FetchProfile profile = new FetchProfile();
profile.add(FetchProfile.Item.ENVELOPE);
Message[] messages = inbox.getMessages();
inbox.fetch(messages, profile);
System.out.println("Inbox Number of Message" + messages.length);
/*for (int i = 0; i < messages.length; i++) {

String from = decodeText(messages[i].getFrom()[0].toString());
InternetAddress ia = new InternetAddress(from);
System.out.println("FROM:" + ia.getPersonal() + '(' +
ia.getAddress() + ')');

System.out.println("TITLE:" + messages[i].getSubject());

System.out.println("DATE:" + messages[i].getSentDate());
}*/
} finally {
try {
inbox.close(false);
} catch (Exception e) {
System.out.println(e.toString());
}
try {
store.close();
} catch (Exception e) {
System.out.println(e.toString());
}
}
}

protected static String decodeText(String text) throws UnsupportedEncodingException {
if (text == null)
return null;
if (text.startsWith("=?GB") || text.startsWith("=?gb"))
text = MimeUtility.decodeText(text);
else
text = new String(text.getBytes("ISO8859_1"));
return text;
}

}

Mail Sender

package mail;

import java.security.Security;

import java.util.Date;

import java.util.Properties;

import javax.mail.Authenticator;
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.PasswordAuthentication;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.AddressException;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;

public class GmailSender {

public static void main(String[] args) throws AddressException,
MessagingException {


Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());
final String SSL_FACTORY = "javax.net.ssl.SSLSocketFactory";
// Get a Properties object
Properties props = System.getProperties();
props.setProperty("proxySet", "true");
//props.setProperty("http.ProxyHost", "192.168.0.6");
//props.setProperty("http.ProxyPort", "8181");
props.setProperty("mail.smtp.host", "smtp.gmail.com");
props.setProperty("mail.smtp.socketFactory.class", SSL_FACTORY);
props.setProperty("mail.smtp.socketFactory.fallback", "false");
props.setProperty("mail.smtp.port", "465");
props.setProperty("mail.smtp.socketFactory.port", "465");
props.put("mail.smtp.auth", "true");
props.put("mail.debug", "true");
props.put("mail.store.protocol", "pop3");
props.put("mail.transport.protocol", "smtp");
final String username = "from@gmail.com";
final String password = "password";
Session session =
Session.getDefaultInstance(props, new Authenticator() {
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(username, password);
}
});

// -- Create a new message --
Message msg = new MimeMessage(session);

// -- Set the FROM and TO fields --
msg.setFrom(new InternetAddress("from@gmail.com"));
msg.setRecipients(Message.RecipientType.TO,
InternetAddress.parse("to@gmail.com",
false));
msg.setSubject("Hello");
msg.setText("How are you");
msg.setSentDate(new Date());
Transport.send(msg);
System.out.println("Message sent.");
}
}