Friday, February 28, 2014

How to display schema size with SQL query in Oracle?




SELECT sum(bytes)
  FROM dba_segments
 WHERE owner = <<owner of schema>>
If you are logged in to the schema then,
 SELECT SUM(bytes) FROM user_segments

Wednesday, February 19, 2014

How to find the Class/Object which invoke a method ?


Throwable t = new Throwable(); 
StackTraceElement[] elements = t.getStackTrace(); 
String calleeMethod = elements[0].getMethodName(); 
String callerMethodName = elements[1].getMethodName(); 
String callerClassName = elements[1].getClassName(); 

Saturday, February 15, 2014

How to Set send from in mail session



Use the setFrom() method:
Session mailSession = Session.getInstance(props, null);
MimeMessage message = new MimeMessage(mailSession);
message.setFrom(new InternetAddress("sendingaddress@company.com"));

How to over ride Netbeans wizard toolbar save button function?


Read here :

https://blogs.oracle.com/geertjan/entry/bye_savecookie_hello_org_netbeans

How to import data into a user when another user with same data exists



Facing ORA-39151 error while trying to import data into a user when there is another user with same tables ??


Answer


impdp user/password DUMPFILE=file_name directory=dir LOGFILE=test.log REMAP_SCHEMA=USERA:USERB TABLE_EXISTS_ACTION=APPEND
USER A is the existing user USER B is the new user

How to get the selected row of a tree table?


//TreeViewer viewer use your viewer
IStructuredSelection selection = (IStructuredSelection)viewer.getSelection();

How to auto adjust window size based on Image size in Java Swing


1. Put image as Icon / ImageIcon to the JLabel then
  • Test for MaximumSize for JFrame that returned Toolkit for concrete monitor
  • If PreferedSize is lower than MaximumSize size then call JFrame#pack()
  • otherwise have to call setSize()

2.Put image as Icon / ImageIcon by using Custom Painting to theJComponentJPanelJLabel e.i. then
  • then this JComponent must to returns PreferredSize
    a) call JFrame#pack() if PreferedSize is lower than MaximumSize,
    b) otherwise have to call JFrame#setSize()
    c) by assume that you don't use Image#getScalledInstance

3.Use Icon in the JLabel, there is only one issue that image can be smaller then expected size on the screen, but no issue with that, is pretty possible to centering image to the JLabel.CENTERto the JLabel

Wednesday, February 12, 2014

How to setup Apache Tomcat Server in Netbeans.


Tomcat 7 is a Servlet Container – a fairly light weight container, very convenient for development and testing. While not a full application server, Tomcat implements the functionality described in the Java Enterprise Edition Web profile specifications. Most notably, it supports version 3.0 of the Servlet API (application programming interface) and version 2.2 of JavaServer Pages, both part of the recently ratified JEE 6.
Installing Tomcat 7 is dead-easy and configuring Tomcat as Server in NetBeans to allow direct (re)deployment of web applications from within NetBeans is just as easy. Still, a brief blog article explaining the steps – for even easier lives for Java Web developers. And as testimonial to the ease of use the development teams behind Tomcat and NetBeans provide to the world of Java developers.
Installation of Tomcat starts with downloading Tomcat, from the Apache site: http://tomcat.apache.org/download-70.cgi



After downloading the zip-file, I extracted it to c:\java (the location is of your own choosing though).

Next I turn to NetBeans to configure Tomcat 7 as a new server.
Open the Tools menu and select the option Servers:

The list of currently configured servers appears. Underneath is the big Add Server button. Press that button.


Select the type of Server to add and provide a name for it – just for reference within NetBeans.


Press Next.


Provide the location where this server instance is installed – the target directory for the extraction of Tomcat 7. Also provide credentials for a Tomcat Administrator account ( in my case I used admin/admin).
Press Finish.
The newly configured Server is presented:


Press Close.
Now the Tomcat 7 Server can be started (and stopped, deployed to etc.) from within NetBeans. Open the Services Window (from the Window menu – option Services or using Ctrl-5).


The Tomcat output console appears in NetBeans:



After a few seconds, Tomcat is running. The home page can be accessed at http://server:port – in my case localhost and port 8085:


Tomcat is now ready to have applications deployed to it – for example from within NetBeans.
Note: in order for the admin user to also access the management console at http://localhost:8085/manager/html it is imperative that this user is granted the manager-gui role. This can be done by editing the tomcat-users.xml file in the conf directory of the Tomcat installation and adding this role. The entry for user admin would then become:
<user password=”admin” roles=”manager-script,admin,manager-gui” username=”admin”/>


http://technology.amis.nl/2012/01/02/installing-tomcat-7-and-configuring-as-server-in-netbeans/



Tuesday, February 11, 2014

How to put Conditional Breakpoints in Netbeans.

Conditional Breakpoints in NetBeans

As of NetBeans 6.x, most types of breakpoints (line, method, field, exception) can be conditioned by a user defined expression.
The expression is evaluated in the place of breakpoint hit and must be of boolean type.

Examples of conditions:
  • x > 1 && y < 10
  • text.equals(name)

In order to modify these conditions, open the "Breakpoint Properties" dialog using one of these methods:
  • Right-click the breakpoint and click Breakpoint > Properties
  • Open the Breakpoints window, right-click on the breakpoint and select Properties