Windows 7 – Downloads folder refreshes really slowly

So this is a nuisance for quite a while, when you open the Downloads folder on Windows 7 it takes a long time before the contents is displayed. It keeps taking longer and longer when there are more and more items there.
Apparently this is because the folder is optimized for Pictures. You can change this setting by right clicking the Downloads folder and choose properties. Then select the tab “Custimize” and look at the setting “Optimize this folder for:”
The folder contents is instantanious when you change that to “General Items”.
Image

Mark or colour NULL values in SQL Developer

By default SQL Developer shows null values in the following way:

Screenshot - SQL Developer - Default Null value
Screenshot – SQL Developer – Default Null value

This is not very notable, so we’ll change it to the following markup:
Screenshot - SQL Developer - What an awesome NULL color!
Screenshot – SQL Developer – What an awesome NULL color!

To do this, we need to go to Preferences – Database – Advanced and change the value for “Display Null Using Background Color”
Screenshot - SQL Developer - Settings for colouring NULL values
Screenshot – SQL Developer – Settings for colouring NULL values

Format Painter shortcut in Microsoft Excel

I’ve been working in Excel a lot the past weeks and often need to fix the formatting. A nice little trick to copy the formatting for a cell, row or column is the format painter, but it’s a hassle to keep clicking on all the ribbons to actually press the button! It was one of the few things in Excel where I would use the mouse.
 

Screenshot - Microsoft Excel - Format Painter
Screenshot – Microsoft Excel – Format Painter

 
There is an easier way to “Format Paint”:
Right click Format Painter, and click “Add to Quick Access Toolbar”, as shown in the next screenshot:
 
Screenshot - Microsoft Excel - Format Painter - Add to QAT
Screenshot – Microsoft Excel – Format Painter – Add to QAT

 
After this step, you will have a small button at the top of your screen with the Format Painter, which you can access via “Alt + <<NUMBER>>”,
in my case it’s “ALT + 4”:
 
Screenshot - Microsoft Excel - Format Painter in the QAT
Screenshot – Microsoft Excel – Format Painter in the QAT

 

Fake SMTP server! Great for testing email / SMTP!

Often in projects you will be asked to send an email when an error occurs, or as a part of the functional process.
Unfortunatly it is sometimes a bit cumbersome to make sure you are not sending mail to real email addresses.. I’ve recently found a nice solution for this problem: a fake SMTP server!
This way, you only have to change the IP address on your SMTP endpoint instead of checking every emailaddress or disabling all the actual email functionality.
 
The application is called “FakeSMTP” (What’s in a name?) 🙂 and can be found through this link: http://nilhcem.github.com/FakeSMTP/index.html

Screenshot - FakeSMTP Main screen
Screenshot – FakeSMTP Main screen

As you can see in the screenshot, the program runs on the port you assign to it, acting as an email server with all the correct responses, with the only difference that it does not actually send out the emails. The emails are stored in a folder which you can specify. You can also double click on the message row in the program to open the email in your email client (in my case Outlook) which worked great for testing purposes.
I was quite pleased when I found this solution :-), hope it will help you guys too!

Oracle Service Bus SFTP: BEA-381801 InvalidHostFileException

I have just been working on an OSB SFTP business service, and got this error while testing the service.
While googling, I found out that you need to create a known_hosts file inside your OSB domain. The easiest way of creating a known_hosts file for me, was to use Cygwin and create a ssh (or sftp) connection to the destination.

Steps for the solution:

  • Cygwin: log in to remote system via ssh (or sftp)
  • Copy known_hosts file from ~/.ssh to OSB directory
  • Test business service

Cygwin: login to remote system

Use this command to login to the remote system:

ssh username@hostname

Optionally: Type ‘yes’ when asked if you trust this host
This will create an entry in your known_hosts file in the .ssh folder in your cygwin home directory
This is a (scrambled) contents of the known_hosts file:

joris@jorisworkstation/cygdrive/c/Oracle/Middleware/user_projects/domains/joris_domain/config/osb
$ cat ~/.ssh/known_hosts
10.200.242.65 ssh-rsa <<INSERT A LOT OF GARBLEGARBLE>>

Copy the known_hosts file to OSB

First we need to create the SFTP transports directory in the domain home:
Go to <<domain_home>>/config/osb and create this structure: (Only create the directories in RED)

- <<domain_home>>
- config
- osb
- transports
- sftp

We are now ready to copy the known_hosts file:
In cygwin:

 cp ~/.ssh/known_hosts /cygdrive/c/Oracle/Middleware/user_projects/domains/joris_domain/config/osb/transports/sftp

In Windows: Find known_hosts in your cygwin home folder (in my case: in C:\development\program\cygwin\home\joris.visscher\.ssh\known_hosts) and copy it to the newly created “sftp” folder in your domain home.

Test business service

All steps are now done, we can test the business service!

Additional information:

You will encounter the following error in your logs when this error occurs:
com.sshtools.j2ssh.transport.InvalidHostFileException

####<18-ott-2012 10.57.33 CEST> <Error> <SFTPTransport> <JORISWORKSTATION> <osb_server1> <[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)'> <<anonymous>> <> <cef9dbcf0859648a:31ba6f:13a730795ec:-8000-000000000000014f> <1350550653493> <BEA-381801> <Si ▒ verificato un errore per l'endpoint com.bea.wli.sb.transports.TransportException: com.sshtools.j2ssh.transport.InvalidHostFileException: Il file known_hosts non esiste o non dispone di autorizzazioni di lettura.
 com.bea.wli.sb.transports.TransportException: com.sshtools.j2ssh.transport.InvalidHostFileException: Il file known_hosts non esiste o non dispone di autorizzazioni di lettura.
 at com.bea.wli.sb.transports.sftp.connector.SFTPTransportProvider.sendMessage(SFTPTransportProvider.java:155)
 at com.bea.wli.sb.transports.sftp.connector.SFTPTransportProvider.sendMessageAsync(SFTPTransportProvider.java:110)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
 at java.lang.reflect.Method.invoke(Method.java:597)
 at com.bea.wli.sb.transports.Util$1.invoke(Util.java:83)
 at $Proxy122.sendMessageAsync(Unknown Source)
 at com.bea.wli.sb.transports.LoadBalanceFailoverListener.sendMessageAsync(LoadBalanceFailoverListener.java:148)
 at com.bea.wli.sb.transports.LoadBalanceFailoverListener.sendMessageToServiceAsync(LoadBalanceFailoverListener.java:603)
 at com.bea.wli.sb.transports.LoadBalanceFailoverListener.sendMessageToService(LoadBalanceFailoverListener.java:538)
 at com.bea.wli.sb.transports.TransportManagerImpl.sendMessageToService(TransportManagerImpl.java:566)
 at com.bea.wli.sb.transports.TransportManagerImpl.sendMessageAsync(TransportManagerImpl.java:434)
 at com.bea.wli.sb.test.service.ServiceMessageSender.send0(ServiceMessageSender.java:380)
 at com.bea.wli.sb.test.service.ServiceMessageSender.access$000(ServiceMessageSender.java:79)
 at com.bea.wli.sb.test.service.ServiceMessageSender$1.run(ServiceMessageSender.java:137)
 at com.bea.wli.sb.test.service.ServiceMessageSender$1.run(ServiceMessageSender.java:135)
 at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:363)
 at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:146)
 at com.bea.wli.sb.security.WLSSecurityContextService.runAs(WLSSecurityContextService.java:55)
 at com.bea.wli.sb.test.service.ServiceMessageSender.send(ServiceMessageSender.java:140)
 at com.bea.wli.sb.test.service.ServiceProcessor.invoke(ServiceProcessor.java:454)
 at com.bea.wli.sb.test.TestServiceImpl.invoke(TestServiceImpl.java:172)
 at com.bea.wli.sb.test.client.ejb.TestServiceEJBBean.invoke(TestServiceEJBBean.java:167)
 at com.bea.wli.sb.test.client.ejb.TestService_sqr59p_EOImpl.__WL_invoke(Unknown Source)
 at weblogic.ejb.container.internal.SessionRemoteMethodInvoker.invoke(SessionRemoteMethodInvoker.java:40)
 at com.bea.wli.sb.test.client.ejb.TestService_sqr59p_EOImpl.invoke(Unknown Source)
 at com.bea.wli.sb.test.client.ejb.TestService_sqr59p_EOImpl_WLSkel.invoke(Unknown Source)
 at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:667)
 at weblogic.rmi.cluster.ClusterableServerRef.invoke(ClusterableServerRef.java:230)
 at weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:522)
 at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:363)
 at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:146)
 at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:518)
 at weblogic.rmi.internal.wls.WLSExecuteRequest.run(WLSExecuteRequest.java:118)
 at weblogic.work.ExecuteThread.execute(ExecuteThread.java:252)
 at weblogic.work.ExecuteThread.run(ExecuteThread.java:221)
 Caused By: com.sshtools.j2ssh.transport.InvalidHostFileException: Il file known_hosts non esiste o non dispone di autorizzazioni di lettura.
at com.bea.wli.sb.transports.sftp.client.KnownHostVerifier.validateKnownHosts(KnownHostVerifier.java:144)
at com.bea.wli.sb.transports.sftp.client.SFTPClient.authenticate(SFTPClient.java:108)
 at com.bea.wli.sb.transports.sftp.connector.SFTPResource.<init>(SFTPResource.java:78)
 at com.bea.wli.sb.transports.sftp.resource.SFTPUtils.createSFTPResource(SFTPUtils.java:170)
 at com.bea.wli.sb.transports.sftp.resource.SFTPConnectionPool.getResource(SFTPConnectionPool.java:104)
 at com.bea.wli.sb.transports.sftp.connector.SFTPTransportProvider.getSFTPResource(SFTPTransportProvider.java:958)
 at com.bea.wli.sb.transports.sftp.connector.SFTPTransportProvider.sendMessage(SFTPTransportProvider.java:145)
 at com.bea.wli.sb.transports.sftp.connector.SFTPTransportProvider.sendMessageAsync(SFTPTransportProvider.java:110)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
 at java.lang.reflect.Method.invoke(Method.java:597)
 at com.bea.wli.sb.transports.Util$1.invoke(Util.java:83)
 at $Proxy122.sendMessageAsync(Unknown Source)
 at com.bea.wli.sb.transports.LoadBalanceFailoverListener.sendMessageAsync(LoadBalanceFailoverListener.java:148)
 at com.bea.wli.sb.transports.LoadBalanceFailoverListener.sendMessageToServiceAsync(LoadBalanceFailoverListener.java:603)
 at com.bea.wli.sb.transports.LoadBalanceFailoverListener.sendMessageToService(LoadBalanceFailoverListener.java:538)
 at com.bea.wli.sb.transports.TransportManagerImpl.sendMessageToService(TransportManagerImpl.java:566)
 at com.bea.wli.sb.transports.TransportManagerImpl.sendMessageAsync(TransportManagerImpl.java:434)
 at com.bea.wli.sb.test.service.ServiceMessageSender.send0(ServiceMessageSender.java:380)
 at com.bea.wli.sb.test.service.ServiceMessageSender.access$000(ServiceMessageSender.java:79)
 at com.bea.wli.sb.test.service.ServiceMessageSender$1.run(ServiceMessageSender.java:137)
 at com.bea.wli.sb.test.service.ServiceMessageSender$1.run(ServiceMessageSender.java:135)
 at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:363)
 at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:146)
 at com.bea.wli.sb.security.WLSSecurityContextService.runAs(WLSSecurityContextService.java:55)
 at com.bea.wli.sb.test.service.ServiceMessageSender.send(ServiceMessageSender.java:140)
 at com.bea.wli.sb.test.service.ServiceProcessor.invoke(ServiceProcessor.java:454)
 at com.bea.wli.sb.test.TestServiceImpl.invoke(TestServiceImpl.java:172)
 at com.bea.wli.sb.test.client.ejb.TestServiceEJBBean.invoke(TestServiceEJBBean.java:167)
 at com.bea.wli.sb.test.client.ejb.TestService_sqr59p_EOImpl.__WL_invoke(Unknown Source)
 at weblogic.ejb.container.internal.SessionRemoteMethodInvoker.invoke(SessionRemoteMethodInvoker.java:40)
 at com.bea.wli.sb.test.client.ejb.TestService_sqr59p_EOImpl.invoke(Unknown Source)
 at com.bea.wli.sb.test.client.ejb.TestService_sqr59p_EOImpl_WLSkel.invoke(Unknown Source)
 at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:667)
 at weblogic.rmi.cluster.ClusterableServerRef.invoke(ClusterableServerRef.java:230)
 at weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:522)
 at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:363)
 at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:146)
 at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:518)
 at weblogic.rmi.internal.wls.WLSExecuteRequest.run(WLSExecuteRequest.java:118)
 at weblogic.work.ExecuteThread.execute(ExecuteThread.java:252)
 at weblogic.work.ExecuteThread.run(ExecuteThread.java:221)

Create sample XML message from XSD in Eclipse (Free solution!)

On an Oracle Service Bus project you are often supplied with XSD’s or WSDL’s when you’re integrating with clients. The customer or client expects you to test their web service but before you do, you might want to take a look at the XML which should be sent to make sure you’re sending compliant XML.
One way to do this is by importing the WSDL in SoapUI and creating sample test requests, this comes in quite handy when you are actually using a WSDL, but what if the customer only supplies an XSD? SoapUI does not support creating sample XML from an XSD element.
There are several commercial products which can solve this problem but if you’re only looking for generating sample XML messages from XSD, you might want to look at using Eclipse’s built in XML generating option:
First step is to import the XSD in your project, the right click the Schema and select “Generate” and then “XML”

Screenshot - Eclipse - Generate XML from XSD
Screenshot – Eclipse – Generate XML from XSD

You will be presented with a “New XML file” dialogue which lets you save your new XML sample. Choose any location you want, and click “Next”. Then you will be presented with the options for your new XML sample. Select the options you desire and press “Finish”
Screenshot - Generate XML - New file dialogue
Screenshot – Generate XML – New file dialogue

Your new XML file has been generated and ofcourse is compliant with your XSD right now!

Unlock HR user and schema in Oracle Database

In an Oracle database there is a sample user called “HR”. This user comes with a schema which contains data which is quite convenient for demo purposes.
You can unlock this user using the following steps:

  1. Connect to your database with the system user
  2. Execute the following command (Note: replace “password” with your password)
    ALTER USER HR IDENTIFIED BY password ACCOUNT UNLOCK;
  3. Log in to the database with the HR user and your specified password

You can use this user for tutorials / demo’s in almost all Oracle databases since the tables are all equal.

Screenshot - Tables, Views and Procedures for the HR user
Screenshot – Tables, Views and Procedures for the HR user

Ps. I’ve posted this small tutorial mainly because it will serve as a prerequisite for other tutorials.

Schema size in Oracle DB

I’ve been running out of disk space on my virtual machine and didn’t want to mount another volume to add more room (because the problem isn’t more room; it’s that I’m sloppy with disk space) 🙂
So I was looking around on how to easily query for the schema size to find out which little project of mine was taking up way too much room. I found a nice solution on this blog:

SELECT tablespace_name
 , SUM(bytes)/1024/1024 AS total_size_mb
 FROM dba_segments
 WHERE owner = Upper('&User_Name')
 GROUP BY owner
 , rollup(tablespace_name);

When you run the query it’ll ask you which user you want to check:

Screenshot - SQL Developer - Query for schema size
Screenshot – SQL Developer – Query for schema size

SQL Developer, Comma's before columns!

I’ve been using SQL Developer a lot lately for data analysis and I’ve been getting used to the auto formatting to easily create well readable code out of my garbled-“I’m in a hurry”-SQL-mess.
This works like a charm, except for the comma’s which kept showing up at the end of the column names after the auto formatting, a small annoyance which is easily solved with this trick.
This is the default auto-formatting which is used by SQL Developer:

SELECT t1.column1,
 t1.column2,
 t2.column3
FROM table1 t1
JOIN table2 t2
ON t1.value1 = t2.value2;

You can change this behaviour by accessing the following settings:
Tools -> Preferences -> Database -> SQL Formatting -> Oracle Formatting -> Press button “Edit”
In the Oracle Formatting window: Line-breaks -> Select “Before comma” and deselect “After comma”

 
After this trick, the default formatting will have this code as a result:

SELECT t1.column1
, t1.column2
, t2.column3
FROM table1 t1
JOIN table2 t2
ON t1.value1 = t2.value2;
 

Happy querying! 🙂

Select sample WS Callouts straight from your Oracle DB

It’s often nice to have the most recent data when you want to test a web service, so in the best scenario you would want to query existing data with some criteria such as active contracts and/or within a certain range.
This example will show you how to get ready-to-use web service callout requests from SQL Developer (or any other SQL tool) which can be used in a Service Bus Console or SoapUI. We will use the HR example database -which can be found in every Oracle DB- as the source.
This is the request which we’ll use:

select '<v1:IncreaseSalaryRequest xmlns:v1="http://example.joris.visscher/hr/types/v1/">
 <v1:EmployeeId>
 <v1:Type>DEFAULT</v1:Type>
 <v1:Identifier>'||emp.employee_id||'</v1:Identifier>
 </v1:EmployeeId>
 <v1:FirstName>'||emp.first_name||'</v1:FirstName>
 <v1:LastName>'||emp.last_name||'</v1:LastName>
 <v1:Department>
 <v1:Type>DEFAULT</v1:Type>
 <v1:Identifier>'||dep.department_id||'</v1:Identifier>
 </v1:Department>
 </v1:IncreaseSalaryRequest>' WSRequest
from employees emp
, departments dep
where emp.department_id = dep.department_id
-- Let's add some conditions which are needed to finish the process succesfully.
and emp.last_name is not null
and dep.department_name = 'IT' -- return the most valuable employees
-- We only need 5 results.
and rownum <= 5;

This will result in five instantly usable requests from live data so we’ll know for sure that all the criteria that should be met for a functional correct case are indeed met:

<v1:IncreaseSalaryRequest xmlns:v1="http://example.joris.visscher/hr/types/v1/">
  <v1:EmployeeId>
    <v1:Type>DEFAULT</v1:Type>
    <v1:Identifier>103</v1:Identifier>
  </v1:EmployeeId>
  <v1:FirstName>Alexander</v1:FirstName>
  <v1:LastName>Hunold</v1:LastName>
  <v1:Department>
    <v1:Type>DEFAULT</v1:Type>
    <v1:Identifier>60</v1:Identifier>
  </v1:Department>
</v1:IncreaseSalaryRequest>

This query should work on most databases, but it works on an Oracle DB for sure 🙂
Happy testing!

Oracle SQL developer queries an OracleXE11g db on Ubuntu 11.10