Wednesday, July 11, 2007

autoexec.bat example

Instead of defining those variables in the MyComputer/Properties/Advanced/EnvironmentVariable menu, just define them in the C:/autoexec.bat file .


set JAVA_HOME=c:\sdk\jdk_1.6.0
set CYGWIN_HOME=C:\dev\frag\bin\win32\cygwin\
REM set CYGWIN_HOME=C:\sdk\cygwin\
set HOME=c:/home/michaelz
set ANT_HOME=c:\sdk\apache-ant-1.6.5\

REM for some reason, I could split this line in several lines ...
REM set PATH=%CYGWIN_HOME%\bin;%PATH%
REM set PATH=%YOUR_KIT%;%PATH%
Publish Post
PATH=%JAVA_HOME%\bin;c:\sdk\cmd;%CYGWIN_HOME%\bin;%ANT_HOME%\bin

Tuesday, July 3, 2007

Read User Input

Here's a simple way to read user input from the standard input (stdin) console:


/**
* Display the given prompt and return the text types by the user (after his first Enter)

* @param prompt text to write in the stdout. Generaly used for asking the user to type something.
* @return userInput - text given by user in the console (stdout)
*/
public static String readUserInput(String prompt) {
System.out.println(prompt + " ( Type to confirm.) ");

BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));
String userInput = "";
try {
userInput = bufferedReader.readLine();
if(log.isInfoEnabled()) {
log.info("Thanks ! ");
}
} catch (IOException ioe) {
log.error("Unable to read user input, Exception : " + ioe.getMessage());
}
return userInput;
}

JVM arguments

  1. JConsole
    Enable jconsole by adding the following:
    -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=7091 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false

    The main argument is
    -Dcom.sun.management.jmxremote. It's not required anymore in JDK 1.6 . The other arguments are used for specifying explicitely the port number (7091). Useful for monitoring a JVM from a remote computer.
  2. YourKit
    For enabling YourKIT Java profiler, add
    -agentlib:yjpagent to your JVM argument.
    In addition, the YourKit/bin directory should be added to the path
  3. Remote debug
    For enabling remote debugger, add the following argument to the JVM:
    -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=1044
  4. JPS for getting all the monitoreable JVM

Wednesday, June 13, 2007

Working Environment

Here's a description of my working environment: my IDE, my plugins, my hacks etc

  • Eclipse
  • Cygwin
  • XEmacs for Windows
  • YourKit - wonderful java profiler
  • WinMerge - for comparing text files
  • Total Commander - FTP utility
  • junction link magic - creating shortcut (links just like in unix) in windows
  • notepad++ or textpad
  • Xsession (XconnectPro) for enabling Xwindows from a simple remote console window.
  • SAP Java Memory Analyzer

  • Eclipse plugins
    • checkstyle
    • PMD ( never really used it. Use it together with checkstyle)
    • Quickmark (like jump to register in emacs)
    • EcSplorer - get explorer from eclipse. I didnt really use it.
    • Easy Explorer - same as above. If I remember, I use it for opening a Windows Explorer directly from my eclipse
    • AspectJ
    • logFileTools - utility for tailing file - nice but I preferred the cygwin for such kind of things.

Saturday, May 12, 2007

Memory Disk usage of user in tablespace database

http://vsbabu.org/oracle/sect03.html


This following SQL display the usage of each table / user within the BE_LARGE_DATA tablespace.
Useful if you want to find the motherf*** which stucked your database.

select OWNER,
sum(BYTES)
from dba_segments t
where TABLESPACE_NAME like 'BE_LARGE_DATA'
and OWNER not in ('SYS','SYSTEM')
group by t.OWNER;

or in more detailed way :

select OWNER,
SEGMENT_NAME,
SEGMENT_TYPE,
TABLESPACE_NAME,
BYTES
from dba_segments
where TABLESPACE_NAME like 'BE_LARGE_DATA'
and OWNER not in ('SYS','SYSTEM')
order by OWNER, SEGMENT_NAME

Tuesday, April 10, 2007

פת שחרית

הוה נתחכמה לו ונבדוק את יכולות העיברית של google.

Sunday, March 25, 2007

Maximum Open Cursor Exceeded

Finding out what is the part of the code that doesn't close the connection or a ResultSet can be endless.
I'm still in the middle of my bug tracking :( but I found here some precious tips:

http://orafaq.com/node/758

In shortcuts, you can find below the main SQL that you'll report you how many opened cursors you currently have and which module/user acquired them:

select max(a.value) as highest_open_cur, p.value as max_open_cur from v$sesstat a, v$statname b, v$parameter p where a.statistic# = b.statistic# and b.name = 'opened cursors current' and p.name= 'open_cursors' group by p.value;

or

select a.value, s.username, s.sid, s.serial# from v$sesstat a, v$statname b, v$session s where a.statistic# = b.statistic# and s.sid=a.sid and b.name = 'opened cursors current';

Or for a more compact view:

select sum(a.value) total_cur, avg(a.value) avg_cur, max(a.value) max_cur, s.username, s.machine from v$sesstat a, v$statname b, v$session s where a.statistic# = b.statistic# and s.sid=a.sid and b.name = 'opened cursors current' group by s.username, s.machine order by 1 desc;


http://forums.oracle.com/forums/thread.jspa?threadID=487567&tstart=0

Wednesday, February 14, 2007

Daily Learning

Each day (or each week ( or each year ) ) , I'll try to post a new learning: something new that I've learned or discovered ... It will be probably in software or in life .

At the end of my life, I'll compile this blog into a book, style Je Me Souviens, of Georges Perec

I'll try to do it in english ( or in french ( or in hebrew ) ) ...

Remote debugger

I already knew that we can attach a debugger ( like Eclipse Debugger) to a remote JVM, as long as it's based on an application server ( J2EE like JBoss etc ).
I've learned today that, very easily, we can also debug a simple Java application ( J2SE) using the following arguments:

-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=1044

And here are the explanation of the arguments, as I found them in this jacoozi thinking solutions site


The jdb parameters specify the way debugger will operate. For instance transport=dt_socket instructs the JVM that the debugger connections will be made through a socket while the address=1044 parameter informs it that the port number will be 1044. Similarly, if you substitute suspend=y, the JVM starts in suspended mode and stays suspended until a debugger is attached to it. This may be helpful if you want to start debugging as soon as the JVM starts.


For the Eclipse Remote Debugger option, you can have a glimpse here or here.

SQL Tips

Select disctinct


How to count distinct rows within table

select count(*) from ( select distinct d1, d2, d3 , d4, d5, d6, d7, d8, d9 from in_all )


Update/Insert table


How to pass data from table to table:

For ex: pass data from table_b to table_a
truncate table TABLE_A
insert into TABLE_A select * from TABLE_B
truncate is different than the delete from TABLE command. My colleagues says that truncate command s faster ...