tag:blogger.com,1999:blog-244956682024-03-07T00:50:30.840-08:00I Did Not Know ThatJava Unix SQL OracleJava Manhttp://www.blogger.com/profile/06426420875519987307noreply@blogger.comBlogger25125tag:blogger.com,1999:blog-24495668.post-16184600212026464132010-06-01T21:06:00.000-07:002010-06-01T21:26:29.249-07:00Whats new in JDK 7Below are some new features in JDK 7<br /><br /><br /><ul><li><a class="capsule" href="http://download.java.net/jdk7/docs/technotes/guides/io/enhancements.html#7">NIO 2.0</a> The java.nio.file package and its related package, java.nio.file.attribute, provide comprehensive support for file I/O and for accessing the file system. </li><li><a class="capsule" href="http://java.sun.com/docs/books/tutorial/sdp/sockets/">Sockets Direct Protocol</a> Sockets Direct Protocol (SDP) is a wire protocol developed to support stream connections over InfiniBand fabric. </li><li>Compressed 64-bit object pointers. A technique for compressing 64-bit pointers to fit into 32 bits, which decreases memory and memory-bandwidth consumption and thereby improves performance </li><li> VM support for non-Java languages. VM extensions to support the implementation of non-Java languages at performance levels near to that of the Java language itself.</li><li>Garbage-First GC. A new garbage collector that promises to achieve lower pause times and better predictability than the current CMS collector </li></ul>Java Manhttp://www.blogger.com/profile/06426420875519987307noreply@blogger.com1tag:blogger.com,1999:blog-24495668.post-19454863759409747502009-11-24T10:55:00.004-08:002010-06-01T21:25:00.211-07:00Using regular expressions in JavaBelow is an example of using Java's regular expression functionality to replace the spaces inside of a parenthesis with a underscore:<br /><br /> String inputStr = "1 (2 3) 4 (5 6) 7 8 9";<br /> String thePatternStr = "\\([\\w\\d\\s]*\\)";<br /> Pattern pattern = Pattern.compile(thePatternStr);<br /> Matcher matcher = pattern.matcher(inputStr);<br /> StringBuffer sb = new StringBuffer();<br /> while(matcher.find())<br /> {<br /> String match = matcher.group();<br /> String matchWithUnderscore = match.replace(' ', '_');<br /> matcher.appendReplacement(sb, matchWithUnderscore);<br /> }<br /> matcher.appendTail(sb);<br /> System.out.println("Input string: " + inputStr);<br /> System.out.println("Modified string: " + sb.toString());<br /><br />This should give the following output:<br /><br />Input string: 1 (2 3) 4 (5 6) 7 8 9<br />Modified string: 1 (2_3) 4 (5_6) 7 8 9Java Manhttp://www.blogger.com/profile/06426420875519987307noreply@blogger.com0tag:blogger.com,1999:blog-24495668.post-18330261469936953312009-11-24T10:55:00.003-08:002010-06-01T21:25:00.211-07:00Using regular expressions in JavaBelow is an example of using Java's regular expression functionality to replace the spaces inside of a parenthesis with a underscore:<br /><br /> String inputStr = "1 (2 3) 4 (5 6) 7 8 9";<br /> String thePatternStr = "\\([\\w\\d\\s]*\\)";<br /> Pattern pattern = Pattern.compile(thePatternStr);<br /> Matcher matcher = pattern.matcher(inputStr);<br /> StringBuffer sb = new StringBuffer();<br /> while(matcher.find())<br /> {<br /> String match = matcher.group();<br /> String matchWithUnderscore = match.replace(' ', '_');<br /> matcher.appendReplacement(sb, matchWithUnderscore);<br /> }<br /> matcher.appendTail(sb);<br /> System.out.println("Input string: " + inputStr);<br /> System.out.println("Modified string: " + sb.toString());<br /><br />This should give the following output:<br /><br />Input string: 1 (2 3) 4 (5 6) 7 8 9<br />Modified string: 1 (2_3) 4 (5_6) 7 8 9Java Manhttp://www.blogger.com/profile/06426420875519987307noreply@blogger.com0tag:blogger.com,1999:blog-24495668.post-29687499152418329922008-05-08T17:20:00.000-07:002010-06-01T21:26:29.249-07:00Determine files that are modifiedfind . -mtime -1 -printJava Manhttp://www.blogger.com/profile/06426420875519987307noreply@blogger.com0tag:blogger.com,1999:blog-24495668.post-24458431443964573222007-09-19T09:45:00.000-07:002010-06-01T21:26:29.250-07:00Using Awk to rename multiple filesThe following awk script will rename files named like:<br /><br />_TEST.ABC.123.XML.1231123 <br /><br />to the following<br /><br />TEST.ABC.123.XML<br /><br /><br />for f in `ls _TEST*`<br />do <br />newfile=`echo $f | grep -o TEST.[A-Z]*.[0-9]*.XML`<br />mv $f $newfile<br />doneJava Manhttp://www.blogger.com/profile/06426420875519987307noreply@blogger.com0tag:blogger.com,1999:blog-24495668.post-18306224603155030792007-08-20T12:27:00.000-07:002007-08-20T12:31:36.859-07:00Utility for determining which files a program is usingThe Process Explorer for Windows is a utility for determining which files an application is currently using. This can come in handy especially when you are trying to delete a file but cannot because some process is still using it. I highly recommend it. Below is the URL:<br /><br /><br />http://www.microsoft.com/technet/sysinternals/Utilities/ProcessExplorer.mspxJava Manhttp://www.blogger.com/profile/06426420875519987307noreply@blogger.com0tag:blogger.com,1999:blog-24495668.post-16857375818057431922007-08-17T15:22:00.000-07:002010-06-01T21:25:00.212-07:00JVM parameters to use a debugger for JavaBelow are the JVM arguements that can be used to allow a debugger to connect to your Java application<br /><br />-Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=portJava Manhttp://www.blogger.com/profile/06426420875519987307noreply@blogger.com0tag:blogger.com,1999:blog-24495668.post-1161629896119949692006-10-23T11:56:00.000-07:002006-10-23T11:58:17.696-07:00Drop all tables for Microsoft SQL ServerResource: <a href="http://aspzone.com/blogs/john/archive/2006/07/12/1793.aspx">John's Blog</a><br /><br /><p><span style="font-size:85%;color:#0000ff;">WHILE</span><span style="font-size:85%;"> </span><span style="font-size:85%;color:#808080;">EXISTS(</span><span style="font-size:85%;color:#0000ff;">SELECT</span><span style="font-size:85%;"> [name] </span><span style="font-size:85%;color:#0000ff;">FROM</span><span style="font-size:85%;"> </span><span style="font-size:85%;color:#008000;">sys.tables</span><span style="font-size:85%;"> </span><span style="font-size:85%;color:#0000ff;">WHERE</span><span style="font-size:85%;"> [type] </span><span style="font-size:85%;color:#808080;">=</span><span style="font-size:85%;"> </span><span style="font-size:85%;color:#ff0000;">'U'</span><span style="font-size:85%;color:#808080;">)<br /></span><span style="font-size:85%;color:#0000ff;">BEGIN<br /></span><span style="font-size:85%;color:#0000ff;">DECLARE</span><span style="font-size:85%;"> @table_name </span><span style="font-size:85%;color:#0000ff;">varchar</span><span style="font-size:85%;color:#808080;">(</span><span style="font-size:85%;">50</span><span style="font-size:85%;color:#808080;">)<br /></span><span style="font-size:85%;color:#0000ff;">DECLARE</span><span style="font-size:85%;"> table_cursor </span><span style="font-size:85%;color:#0000ff;">CURSOR</span><span style="font-size:85%;"> </span><span style="font-size:85%;color:#0000ff;">FOR</span><span style="font-size:85%;"> </span><span style="font-size:85%;color:#0000ff;">SELECT</span><span style="font-size:85%;"> [name] </span><span style="font-size:85%;color:#0000ff;">FROM</span><span style="font-size:85%;"> </span><span style="font-size:85%;color:#008000;">sys.tables</span><span style="font-size:85%;"> </span><span style="font-size:85%;color:#0000ff;">WHERE</span><span style="font-size:85%;"> [type] </span><span style="font-size:85%;color:#808080;">=</span><span style="font-size:85%;"> </span><span style="font-size:85%;color:#ff0000;">'U'<br /></span><span style="font-size:85%;color:#0000ff;">OPEN</span><span style="font-size:85%;"> table_cursor<br /></span><span style="font-size:85%;color:#0000ff;">FETCH</span><span style="font-size:85%;"> NEXT </span><span style="font-size:85%;color:#0000ff;">FROM</span><span style="font-size:85%;"> table_cursor </span><span style="font-size:85%;color:#0000ff;">INTO</span><span style="font-size:85%;"> @table_name<br /></span><span style="font-size:85%;color:#0000ff;">WHILE</span><span style="font-size:85%;"> </span><span style="font-size:85%;color:#ff00ff;">@@FETCH_STATUS</span><span style="font-size:85%;"> </span><span style="font-size:85%;color:#808080;">=</span><span style="font-size:85%;"> 0<br /></span><span style="font-size:85%;color:#0000ff;">BEGIN<br /></span><span style="font-size:85%;color:#0000ff;">BEGIN</span><span style="font-size:85%;"> </span><span style="font-size:85%;color:#0000ff;">TRY<br /></span><span style="font-size:85%;color:#0000ff;">EXEC</span><span style="font-size:85%;"> </span><span style="font-size:85%;color:#808080;">(</span><span style="font-size:85%;color:#ff0000;">'DROP TABLE ['</span><span style="font-size:85%;"> </span><span style="font-size:85%;color:#808080;">+</span><span style="font-size:85%;"> @table_name </span><span style="font-size:85%;color:#808080;">+</span><span style="font-size:85%;"> </span><span style="font-size:85%;color:#ff0000;">']'</span><span style="font-size:85%;color:#808080;">)<br /></span><span style="font-size:85%;color:#0000ff;">PRINT</span><span style="font-size:85%;"> </span><span style="font-size:85%;color:#ff0000;">'Dropped Table '</span><span style="font-size:85%;"> </span><span style="font-size:85%;color:#808080;">+</span><span style="font-size:85%;"> @table_name<br /></span><span style="font-size:85%;color:#0000ff;">END</span><span style="font-size:85%;"> </span><span style="font-size:85%;color:#0000ff;">TRY<br /></span><span style="font-size:85%;color:#0000ff;">BEGIN</span><span style="font-size:85%;"> </span><span style="font-size:85%;color:#0000ff;">CATCH</span><span style="font-size:85%;"> </span><span style="font-size:85%;color:#0000ff;">END</span><span style="font-size:85%;"> </span><span style="font-size:85%;color:#0000ff;">CATCH<br /></span><span style="font-size:85%;color:#0000ff;">FETCH</span><span style="font-size:85%;"> NEXT </span><span style="font-size:85%;color:#0000ff;">FROM</span><span style="font-size:85%;"> table_cursor </span><span style="font-size:85%;color:#0000ff;">INTO</span><span style="font-size:85%;"> @table_name<br /></span><span style="font-size:85%;color:#0000ff;">END<br /></span><span style="font-size:85%;color:#0000ff;">CLOSE</span><span style="font-size:85%;"> table_cursor<br /></span><span style="font-size:85%;color:#0000ff;">DEALLOCATE</span><span style="font-size:85%;"> table_cursor<br /></span><span style="font-size:85%;color:#0000ff;">END</span></p>Java Manhttp://www.blogger.com/profile/06426420875519987307noreply@blogger.com0tag:blogger.com,1999:blog-24495668.post-1159304598696617052006-09-26T14:00:00.000-07:002010-06-01T21:26:29.250-07:00Encrypting file on Unix<span style="color:blue;">crypt</span>: Encodes (encrypts) or decodes a file<br /> <b> usage: </b> <span style="color:blue;">crypt</span> [options][file]<br /> <b> options: </b><i>password</i><br /> <b> example: </b> <span style="color:blue;">crypt</span> key <> encrypted.file<br /> <b> example: </b> <span style="color:blue;">crypt</span> key < encrypted.file | lpr<br /><br />Resource:<br /><br />http://www.u.arizona.edu/udocs/unix-cmds.html#cryptJava Manhttp://www.blogger.com/profile/06426420875519987307noreply@blogger.com0tag:blogger.com,1999:blog-24495668.post-1157495223397985792006-09-05T15:25:00.000-07:002006-09-05T15:27:30.913-07:00SQL script to obtain tablespace usage for objects in OracleBelow is a script that will report the amount of space each object (table, index, etc) is taking up in its associated tablespace:<br /><br /><br />select substr(SEGMENT_NAME,1,30) segment_name, SEGMENT_TYPE, substr(tablespace_name,1,30) tablespace_name, bytes/1024/1024 mbytes<br />from user_segments<br />order by mbytes descJava Manhttp://www.blogger.com/profile/06426420875519987307noreply@blogger.com0tag:blogger.com,1999:blog-24495668.post-1147992232717052902006-05-18T15:43:00.000-07:002010-06-01T21:26:29.251-07:00Moving a foreground process to the background in UNIX<p class="MsoNormal" style="font-family: arial;">Below is an example of moving a process already running in the foreground to the background:</p> <p class="MsoNormal" style="font-family:arial;">1) To start we have a script running in the foreground</p> <p face="arial" class="MsoNormal"><span style="text-decoration: none; color: rgb(0, 0, 0);font-family:courier new;" >/home/javaoneman>runTest.sh</span><o:p></o:p></p> <p face="arial" class="MsoNormal">2) Press CTRL-Z to place the process in a suspended state.</p> <p face="arial" class="MsoNormal">The following should appear on the console:</p> <p style="font-family: courier new;" class="MsoNormal">^Z<o:p></o:p></p> <p style="font-family: arial;" class="MsoNormal"><span style="font-family:courier new;">[1]+ Stopped runTest.sh</span><o:p></o:p></p> <p style="font-family: arial;" class="MsoNormal">3) Move the suspended process into the background using the bg command</p> <p style="font-family: courier new;" class="MsoNormal">/home/javaoneman>bg</p> <p style="font-family: arial;" class="MsoNormal">The following confirmation should appear on the console:<o:p></o:p></p> <p style="font-family: courier new;" class="MsoNormal">[1]+ runTest.sh &</p> <p style="font-family: arial;" class="MsoNormal">Thanks to <a href="http://www.cs.dal.ca/studentservices/faq/miscellaneous/process_Management.php">Dalhousie University Computer Science Department</a> for providing this useful information on UNIX process control</p>Java Manhttp://www.blogger.com/profile/06426420875519987307noreply@blogger.com0tag:blogger.com,1999:blog-24495668.post-1146242323783774152006-04-28T09:27:00.000-07:002006-04-28T11:35:45.320-07:00XSL Transform with Ant<span style="color: rgb(0, 0, 0);font-family:arial;" >Ant provides a taskthat will perform an XSL transformation on multiple XML files. Below is an example of using this task:</span><br /><br /><p><span style="color: rgb(0, 0, 0);font-family:Courier;" ><span style="color: rgb(0, 0, 128);font-size:85%;" ><target</span><span style="font-size:85%;"> </span><span style="color: rgb(0, 0, 128);font-size:85%;" >name=</span><span style="color: rgb(0, 128, 0);font-size:85%;" >"TransformAll"</span></span><span style="color: rgb(0, 0, 0);font-family:Courier;" ><span style="color: rgb(0, 0, 128);font-size:85%;" >><br /></span><span style="color: rgb(0, 0, 128);font-size:85%;" > <xslt</span><span style="font-size:85%;"> </span><span style="color: rgb(0, 0, 128);font-size:85%;" >basedir=</span><span style="color: rgb(0, 128, 0);font-size:85%;" >"${basedir}/xml"</span></span><span style="color: rgb(0, 0, 0);font-family:Courier;" ><span style="font-size:85%;"><br /> </span><span style="font-size:85%;"> <span style="color: rgb(0, 0, 128);">destdir=</span></span></span><span style="color: rgb(0, 0, 0);font-family:Courier;" ><span style="color: rgb(0, 128, 0);font-size:85%;" >"${basedir}/html"<br /></span><span style="color: rgb(0, 0, 128);font-size:85%;" > includes=</span></span><span style="color: rgb(0, 0, 0);font-family:Courier;" ><span style="color: rgb(0, 128, 0);font-size:85%;" >"*.xml"<br /> </span><span style="color: rgb(0, 0, 128);font-size:85%;" >style=</span><span style="color: rgb(0, 128, 0);font-size:85%;" >"${basedir}/xslt/test.xsl"</span></span><span style="color: rgb(0, 0, 128);font-family:Courier;font-size:85%;" ><span style="color: rgb(0, 0, 0);font-family:courier new;" >/></span><br /></span><span style="color: rgb(0, 0, 128);font-size:85%;" ><br /></span><span style="font-family:Courier;"><span style="color: rgb(0, 0, 128);font-size:85%;" ><br /><span style="color: rgb(0, 0, 0);font-family:arial;" ><span style="font-size:100%;">The basedir parameter specificies the directory of the files to transform. The includes parameter can be used to filter out specific files in the basedir to transform. The destdir specifies where the transformed files will be stored. The style parameter specifies the XSL file to be used to transform the input files. </span><br /></span></span></span></p><p><span style="font-size:100%;"><span style="font-family:arial;">This information was obtained from </span><span style="font-weight: bold;font-family:arial;" ></span><a style="font-family: arial;" href="Java,%20Eclipse,%20Ant,%20XML,%20JMX%20and%20other%20acronyms">Java, Eclipse, Ant, XML, JMX and other acronyms</a><span style="font-family:arial;"> which provides a lot more useful information than my blog :(. </span></span><br /></p>Java Manhttp://www.blogger.com/profile/06426420875519987307noreply@blogger.com1tag:blogger.com,1999:blog-24495668.post-1146179998781811982006-04-27T16:12:00.000-07:002010-06-01T21:26:29.251-07:00Using sed to remove lines from multiple filesIn addition to searching and replacing content in files, Sed can also remove specific characters from files. This can be done by specifying the '/d' option after the pattern you specific. Below is a script which deletes the DTD header for a list of files in a specific directory using the Sed command:<br /><br /><br />##########################################################<br />#<br /># Script used to delete the DOCTYPE header consisting of<br /># the dtd file path from each xml in a specified directory<br />#<br />##########################################################<br /><br />INPUT_DIR=$1<br /><br />for filename in $INPUT_DIR/*.xml<br />do<br /> echo "removing dtd path for $filename ...."<br /> sed -e '/DOCTYPE/d' $filename > $INPUT_DIR/temp_file<br /> mv -f $INPUT_DIR/temp_file $filename<br />doneJava Manhttp://www.blogger.com/profile/06426420875519987307noreply@blogger.com0tag:blogger.com,1999:blog-24495668.post-1144859505321934042006-04-12T09:28:00.000-07:002010-06-01T21:26:29.251-07:00Unix's find command<h3>Introduction </h3> <p> The find command allows the Unix user to process a set of files and/or directories in a file subtree. </p><p> You can specify the following: </p><ul><li> where to search (pathname) </li><li> what type of file to search for (-type: directories, data files, links) </li><li> how to process the files (-exec: run a process against a selected file) </li><li> the name of the file(s) (-name) </li><li> perform logical operations on selections (-o and -a) </li></ul> <a name="EX01"></a> <h3> Search for file with a specific name in a set of files (-name) </h3> <blockquote> <kbd>find . -name "temp.txt" -print </kbd> </blockquote> <p> This command will search in the current directory and all sub directories for a file named <i>temp.txt</i>. </p><p> Note: The -print option will print out the path of any file that is found with that name. In general -print wil print out the path of any file that meets the find criteria. <a name="EX02"></a> </p><h3> How to apply a unix command to a set of file (-exec). </h3> <blockquote> <kbd>find . -name "temp.txt" -exec chmod o+r '{}' \; </kbd> </blockquote> <p> This command will search in the current directory and all sub directories. All files named <i>temp.txt </i>will be processed by the <i>chmod -o+r</i> command. The argument '{}' inserts each found file into the chmod command line. The \; argument indicates the exec command line has ended. </p><p> The end results of this command is all <i>rc.conf</i> files have the other permissions set to read access (if the operator is the owner of the file). </p><p> <a name="EX03"></a> </p><h3> How to apply a complex selection of files (-o and -a). </h3> <blockquote> <kbd>find /usr/tmp -not \( -name "*,v" -o -name ".*,v" \) '{}' \; -print </kbd> </blockquote> <p> This command will search in the <i>/usr/tmp</i> directory and all sub directories. All files that are of the form '*,v' and '.*,v' are excluded. Important arguments to note are: </p><ul><li> <i>-not</i> means the negation of the expression that follows </li><li> \( means the start of a complex expression. </li><li> \) means the end of a complex expression. </li><li> <i>-o</i> means a logical or of a complex expression.<br />In this case the complex expression is all files like '*,v' or '.*,v' </li></ul> <p> The above example is shows how to select all file that are <i>not</i> part of the RCS system. This is important when you want go through a source tree and modify all the source files... but ... you don't want to affect the RCS version control files. </p><p> </p><p> <a name="EX04"></a> </p><h3> How to search for a string in a selection of files (-exec grep ...). </h3> <blockquote> <kbd>find . -exec grep "foo" '{}' \; -print </kbd> </blockquote> <p> This command will search in the current directory and all sub directories. All files that contain the string will have their path printed to standard output. </p><p> If you want to just find each file then pass it on for processing use the -q grep option. This finds the first occurrance of the search string. It then signals success to find and find continues searching for more files. </p><blockquote> <kbd>find . -exec grep -q "foo" '{}' \; -print </kbd> </blockquote> <p> This command is very important for process a series of files that contain a specific string. You can then process each file appropriately. </p>Java Manhttp://www.blogger.com/profile/06426420875519987307noreply@blogger.com1tag:blogger.com,1999:blog-24495668.post-1144362858667837862006-04-06T15:30:00.000-07:002010-06-01T21:26:29.252-07:00Using lsofThe lsof (stands for list of open files) provides information on file and ports which are opened by any process currently running. Below is an example:<br /><br /># <kbd>lsof -i -nP | grep httpd</kbd><br />httpd 2318 apache 16u IPv4 0x019922bc 0t0 TCP 127.0.0.1:8000 (LISTEN)<br />httpd 2319 apache 16u IPv4 0x019922bc 0t0 TCP 127.0.0.1:8000 (LISTEN)<br />httpd 2322 apache 16u IPv4 0x019922bc 0t0 TCP 127.0.0.1:8000 (LISTEN)Java Manhttp://www.blogger.com/profile/06426420875519987307noreply@blogger.com0tag:blogger.com,1999:blog-24495668.post-1143826657919723072006-03-31T09:36:00.000-08:002010-06-01T21:26:29.252-07:00Example of using Sed<p class="MsoNormal">SED is a stream editor. A stream editor is used to perform basic text transformations on an input stream (a file or input from a pipeline). While in some ways similar to an editor which permits scripted edits (such as ED), SED works by making only one pass over the input(s), and is consequently more efficient. But it is SED's ability to filter text in a pipeline which particularly distinguishes it from other types of editors.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">One of sed's most useful commands is the substitution command. Using it, we can replace a particular string or matched regular expression with another string. For example say we have a file (called test.txt) with the following content:</p> <p class="MsoNormal"><o:p> </o:p></p> <p style="font-family: courier new;" class="MsoNormal"><span style="font-size:85%;">aaa bbb ccc<o:p></o:p></span></p> <p style="font-family: courier new;" class="MsoNormal"><span style="font-size:85%;">eee fff ggg<o:p></o:p></span></p> <p style="font-family: courier new;" class="MsoNormal"><span style="font-size:85%;">bbb ccc aaa<o:p></o:p></span></p> <p style="font-family: courier new;" class="MsoNormal"><span style="font-size:85%;">eee rrr kkk</span></p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">We want to change all the instances of “aaa” to “zzz”. The following sed command could be used to perform the search and replace: </p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal"><span style="font-size:85%;">sed -e 's/aaa/zzz/g' test.txt > out.txt</span></p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">The contents of the output file (out.txt) now has the following:</p> <p class="MsoNormal"><o:p> </o:p></p> <p style="font-family: courier new;" class="MsoNormal">zzz bbb ccc<o:p></o:p></p> <p style="font-family: courier new;" class="MsoNormal">eee fff ggg<o:p></o:p></p> <p style="font-family: courier new;" class="MsoNormal">bbb ccc zzz<o:p></o:p></p> <p style="font-family: courier new;" class="MsoNormal">eee rrr kkk</p>Java Manhttp://www.blogger.com/profile/06426420875519987307noreply@blogger.com2tag:blogger.com,1999:blog-24495668.post-1143740061730793382006-03-30T09:31:00.000-08:002010-06-01T21:26:29.252-07:00Unix shell script to automate FTP processI found the following script below from <a href="http://www.ftpplanet.com/ubb/Forum5/HTML/000191.html">FTP Planet</a> to automate FTP process. It seems to work well but do not recommend leaving your username and password in any script for a extended period of time:<br /><br /><span style="font-family:Verdana, Arial;font-size:85%;">ftp -v -n hostname << EOF<br />user usuario password<br />bin<br />put filename<br />bye<br />EOF</span>Java Manhttp://www.blogger.com/profile/06426420875519987307noreply@blogger.com1tag:blogger.com,1999:blog-24495668.post-1143658511112997792006-03-29T10:52:00.000-08:002010-06-01T21:27:43.466-07:00SQL query to obtain tablespace usageBelow are some queries to obtain the amount of space available as well as total size:<br /><br />-- All size<br />select a.tablespace_name,<br />ROUND(a.bytes,2) "SIZE(MB)",<br />ROUND(a.maxbytes,2) "MAX SIZE(MB)",<br />ROUND(nvl(b.bytes,0),2) "FREE SPACE(MB)",<br /> ROUND((a.bytes - nvl(b.bytes,0)),2) "USED(MB)",<br /> ROUND((a.bytes - nvl(b.bytes,0))/a.bytes*100,2) "PCT USED"<br /> -- ,ROUND((a.bytes - nvl(b.bytes,0))/a.maxbytes*100,2) "PCT MAX USED"<br /> from (<br /> select TABLESPACE_NAME,<br /> sum(BYTES/(1024*1024)) bytes,<br /> sum(decode(MAXBYTES,0,bytes,maxbytes)/(1024*1024)) maxbytes<br /> from dba_data_files<br /> group by TABLESPACE_NAME) a,<br /> (<br /> select TABLESPACE_NAME,<br /> sum(BYTES/(1024*1024)) bytes<br /> from dba_free_space<br /> group by TABLESPACE_NAME) b<br />where a.tablespace_name=b.tablespace_name(+)<br />order by 1;<br /><br />-- tablespace size<br />select tablespace_name, sum(bytes)/1024/1024 mbytes from user_segments<br />group by tablespace_name<br />order by 2 desc;Java Manhttp://www.blogger.com/profile/06426420875519987307noreply@blogger.com0tag:blogger.com,1999:blog-24495668.post-1143586009814906022006-03-28T11:26:00.000-08:002010-06-01T21:27:43.466-07:00Determining SQL statements currently being executed<p class="MsoNormal" style=""><span style="font-family: Arial;">In addition to determine session information, the Oracle data dictionary tables can also be used to determine the current SQL statements being executed. James Koopmann has authored several articles on <a href="http://www.databasejournal.com/">Database Journal</a> regarding monitoring SQL statements. I strongly recommend reading his <a href="http://www.databasejournal.com/features/oracle/article.php/3375351">article</a>. Below are some examples of extracting the SQL statements currently executed on an instance<u1:p></u1:p>:</span><o:p></o:p></p> <p class="MsoNormal" style="" face="courier new"><span style="font-family: "Courier New";">SELECT hash_value,<br />sql_text<br />FROM v$sqlarea<br />WHERE users_executing > 0;<o:p></o:p></span></p> <u1:p></u1:p> <p class="MsoNormal" style="" face="courier new"><span style="font-family: "Courier New";"><u1:p></u1:p>SELECT sesion.sid,<br />sesion.username,<br />optimizer_mode,<br />hash_value,<br />address,<br />cpu_time,<br />elapsed_time,<br />sql_text<br />FROM v$sqlarea sqlarea,<br />v$session sesion<br />WHERE sesion.sql_hash_value = sqlarea.hash_value<br />and sesion.sql_address = sqlarea.address<br />and sesion.username is not null;<o:p></o:p></span></p> <u1:p></u1:p> <p class="MsoNormal"><span style="font-family: "Courier New";">SELECT u.sid,<br />substr(u.username,1,12) user_name,<br />s.sql_text<br />FROM v$sql s,<br />v$session u<br />WHERE s.hash_value = u.sql_hash_value<br />and sql_text not like '%from v$sql s, v$session u%'<br />ORDER BY u.sid;<o:p></o:p></span></p>Java Manhttp://www.blogger.com/profile/06426420875519987307noreply@blogger.com0tag:blogger.com,1999:blog-24495668.post-1143481629355548622006-03-27T09:46:00.000-08:002010-06-01T21:27:43.467-07:00Using Oracle’s explain plan<p class="bp">Use the <code><span style="font-size:10;">EXPLAIN</span></code> <code><span style="font-size:10;">PLAN</span></code> statement to determine the execution plan Oracle follows to execute a specified SQL statement. This statement inserts a row describing each step of the execution plan into a specified table. You can also issue the <code><span style="font-size:10;">EXPLAIN</span></code> <code><span style="font-size:10;">PLAN</span></code> statement as part of the SQL trace facility.<o:p></o:p></p> <p class="bp"><a name="2107509"></a>If you are using cost-based optimization, then this statement also determines the cost of executing the statement. If any domain indexes are defined on the table, then user-defined CPU and I/O costs will also be inserted.<o:p></o:p></p> <p class="bp"><a name="2061803"></a>The definition of a sample output table <code><span style="font-size:10;">PLAN_TABLE</span></code> is available in a SQL script on your distribution media. Your output table must have the same column names and datatypes as this table. The common name of this script is <code><span style="font-size:10;">UTLXPLAN.SQL</span></code>. The exact name and location depend on your operating system.</p> <p class="bp">The <code><span style="font-size:10;">DBMS_XPLAN</span></code> package provides an easy way to format the output of the <code><span style="font-size:10;">EXPLAIN PLAN</span></code> command. Below is an sample SQL which will generate an explain plan and store in the plan table:</p> <pre>EXPLAIN PLAN FOR<o:p></o:p></pre><pre><a name="1001525"></a>SELECT *<o:p></o:p></pre><pre><a name="1001526"></a>FROM emp e, dept d<o:p></o:p></pre><pre><a name="1001527"></a>WHERE e.deptno = d.deptno<o:p></o:p></pre><pre><a name="1001528"></a><span style=""> </span>AND e.ename='su';</pre><pre><o:p><br /></o:p><br /></pre> <p class="bp">Below is example of using the DBMS_XPLAN procedure and the output produced:</p><p class="bp"><span style="font-size:85%;"><span style="font-family: courier new;">SELECT * FROM table(DBMS_XPLAN.DISPLAY);</span></span><br /></p><p class="bp"></p>--------------------------------------------------------------------<o:p></o:p><pre><a name="1001546"></a>| Id<span style=""> </span>| Operation<span style=""> </span>|<span style=""> </span>Name<span style=""> </span>| Rows<span style=""> </span>| Bytes | Cost<span style=""> </span>|<o:p></o:p></pre><pre><a name="1001547"></a>--------------------------------------------------------------------<o:p></o:p></pre><pre><a name="1001548"></a>|<span style=""> </span>0 | SELECT STATEMENT<span style=""> </span>|<span style=""> </span>|<span style=""> </span><span style=""> </span>1 |<span style=""> </span>50 |<span style=""> </span>3 |<o:p></o:p></pre><pre><a name="1001549"></a>|*<span style=""> </span>1 | HASH JOIN<span style=""> </span>|<span style=""> </span>|<span style=""> </span>1 |<span style=""> </span>50 |<span style=""> </span>3 |<o:p></o:p></pre><pre><a name="1001550"></a>|*<span style=""> </span>2 | TABLE ACCESS FULL<span style=""> </span>| EMP<span style=""> </span>|<span style=""> </span>1 |<span style=""> </span>32 |<span style=""> </span>1 |<o:p></o:p></pre><pre><a name="1001551"></a>|<span style=""> </span>3 | TABLE ACCESS FULL<span style=""> </span>| DEPT<span style=""> </span>|<span style=""> </span>4 |<span style=""> </span>72 |<span style=""> </span>1 |<o:p></o:p></pre><pre><a name="1001552"></a>--------------------------------------------------------------------<o:p></o:p></pre><pre><a name="1001577"></a>Predicate Information (identified by operation id)<o:p></o:p></pre><pre><a name="1001585"></a>1 - access("E1"."DEPTNO"="D1"."DEPTNO")<o:p></o:p></pre><pre><a name="1001586"></a>2 - filter("E1"."ENAME"='su')<o:p></o:p></pre>Java Manhttp://www.blogger.com/profile/06426420875519987307noreply@blogger.com0tag:blogger.com,1999:blog-24495668.post-1143226530441883762006-03-24T09:46:00.000-08:002010-06-01T21:27:43.467-07:00Oracle SQL query to determine session information<p class="MsoNormal">The v$session is one of the most useful Oracle data dictionary tables. This table provides information such as<o:p></o:p></p> <ul type="disc"><li class="MsoNormal" style="">The user associated with each session<o:p></o:p></li><li class="MsoNormal" style="">The status of a session (active or inactive)<o:p></o:p></li><li class="MsoNormal" style="">The program associated with the session<o:p></o:p></li><li class="MsoNormal" style="">The machine where the session originated from<o:p></o:p></li></ul> <p class="MsoNormal">This information can be valuable when determining which users or applications are utilizing Oracle. Below is an example of a query that will obtain the number of session associated with each user:<br /><br /><span style=""><span style="font-size:85%;"><span style="font-family:courier new;">select substr(username,1,10) as username, substr(program,1,30) as program,</span><br /><span style="font-family:courier new;">status, substr(machine,1,20) as machine, count(*)</span><br /><span style="font-family:courier new;">from v$session</span><br /><span style="font-family:courier new;">group by username,status,program, machine</span><br /><span style="font-family:courier new;">order by status,program,username;</span></span><br /><br /></span>This query will return a result set like the following:</p> <table class="MsoNormalTable" style="width: 389px; margin-left: 4.65pt; border-collapse: collapse; height: 386px;font-family:verdana;" border="0" cellpadding="0" cellspacing="0"> <tbody><tr style="height: 12.75pt;"> <td style="padding: 0in 5.4pt; width: 82pt; height: 12.75pt;" nowrap="nowrap" valign="bottom" width="109"> <p class="MsoNormal"><span style="font-size:78%;">USERNAME<o:p></o:p></span></p> </td> <td style="padding: 0in 5.4pt; width: 101.45pt; height: 12.75pt;" nowrap="nowrap" valign="bottom" width="135"> <p class="MsoNormal"><span style="font-size:78%;">PROGRAM<o:p></o:p></span></p> </td> <td style="padding: 0in 5.4pt; width: 49pt; height: 12.75pt;" nowrap="nowrap" valign="bottom" width="65"> <p class="MsoNormal"><span style="font-size:78%;">STATUS<o:p></o:p></span></p> </td> <td style="padding: 0in 5.4pt; width: 68.15pt; height: 12.75pt;" nowrap="nowrap" valign="bottom" width="91"> <p class="MsoNormal"><span style="font-size:78%;">MACHINE<o:p></o:p></span></p> </td> <td style="padding: 0in 5.4pt; width: 48pt; height: 12.75pt;" nowrap="nowrap" valign="bottom" width="64"> <p class="MsoNormal"><span style="font-size:78%;">COUNT(*)<o:p></o:p></span></p> </td> </tr> <tr style="height: 12.75pt;"> <td style="padding: 0in 5.4pt; width: 82pt; height: 12.75pt;" nowrap="nowrap" valign="bottom" width="109"> <p class="MsoNormal"><span style="font-size:78%;">-------------<o:p></o:p></span></p> </td> <td style="padding: 0in 5.4pt; width: 101.45pt; height: 12.75pt;" nowrap="nowrap" valign="bottom" width="135"> <p class="MsoNormal"><span style="font-size:78%;">-----------------<o:p></o:p></span></p> </td> <td style="padding: 0in 5.4pt; width: 49pt; height: 12.75pt;" nowrap="nowrap" valign="bottom" width="65"> <p class="MsoNormal"><span style="font-size:78%;">--------<o:p></o:p></span></p> </td> <td style="padding: 0in 5.4pt; width: 68.15pt; height: 12.75pt;" nowrap="nowrap" valign="bottom" width="91"> <p class="MsoNormal"><span style="font-size:78%;">----------<o:p></o:p></span></p> </td> <td style="padding: 0in 5.4pt; width: 48pt; height: 12.75pt;" nowrap="nowrap" valign="bottom" width="64"> <p class="MsoNormal"><span style="font-size:78%;">--------<o:p></o:p></span></p> </td> </tr> <tr style="height: 12.75pt;"> <td style="padding: 0in 5.4pt; width: 82pt; height: 12.75pt;" nowrap="nowrap" valign="bottom" width="109"> <p class="MsoNormal"><span style="font-size:78%;"><o:p> </o:p></span></p> <span style="font-size:78%;"><br /></span></td> <td style="padding: 0in 5.4pt; width: 101.45pt; height: 12.75pt;" nowrap="nowrap" valign="bottom" width="135"> <p class="MsoNormal"><span style="font-size:78%;">oracle@dbsvr<o:p></o:p></span></p> </td> <td style="padding: 0in 5.4pt; width: 49pt; height: 12.75pt;" nowrap="nowrap" valign="bottom" width="65"> <p class="MsoNormal"><span style="font-size:78%;">ACTIVE<o:p></o:p></span></p> </td> <td style="padding: 0in 5.4pt; width: 68.15pt; height: 12.75pt;" nowrap="nowrap" valign="bottom" width="91"> <p class="MsoNormal"><span style="font-size:78%;">dbsvr<o:p></o:p></span></p> </td> <td style="padding: 0in 5.4pt; width: 48pt; height: 12.75pt;" num="" nowrap="nowrap" valign="bottom" width="64"> <p class="MsoNormal" style="text-align: right;" align="right"><span style="font-size:78%;">1<o:p></o:p></span></p> </td> </tr> <tr style="height: 12.75pt;"> <td style="padding: 0in 5.4pt; width: 82pt; height: 12.75pt;" nowrap="nowrap" valign="bottom" width="109"> <p class="MsoNormal"><span style="font-size:78%;"><o:p> </o:p></span></p> <span style="font-size:78%;"><br /></span></td> <td style="padding: 0in 5.4pt; width: 101.45pt; height: 12.75pt;" nowrap="nowrap" valign="bottom" width="135"> <p class="MsoNormal"><span style="font-size:78%;">oracle@dbsvr<o:p></o:p></span></p> </td> <td style="padding: 0in 5.4pt; width: 49pt; height: 12.75pt;" nowrap="nowrap" valign="bottom" width="65"> <p class="MsoNormal"><span style="font-size:78%;">ACTIVE<o:p></o:p></span></p> </td> <td style="padding: 0in 5.4pt; width: 68.15pt; height: 12.75pt;" nowrap="nowrap" valign="bottom" width="91"> <p class="MsoNormal"><span style="font-size:78%;">dbsvr<o:p></o:p></span></p> </td> <td style="padding: 0in 5.4pt; width: 48pt; height: 12.75pt;" num="" nowrap="nowrap" valign="bottom" width="64"> <p class="MsoNormal" style="text-align: right;" align="right"><span style="font-size:78%;">1<o:p></o:p></span></p> </td> </tr> <tr style="height: 12.75pt;"> <td style="padding: 0in 5.4pt; width: 82pt; height: 12.75pt;" nowrap="nowrap" valign="bottom" width="109"> <p class="MsoNormal"><span style="font-size:78%;"><o:p> </o:p></span></p> <span style="font-size:78%;"><br /></span></td> <td style="padding: 0in 5.4pt; width: 101.45pt; height: 12.75pt;" nowrap="nowrap" valign="bottom" width="135"> <p class="MsoNormal"><span style="font-size:78%;">oracle@dbsvr<o:p></o:p></span></p> </td> <td style="padding: 0in 5.4pt; width: 49pt; height: 12.75pt;" nowrap="nowrap" valign="bottom" width="65"> <p class="MsoNormal"><span style="font-size:78%;">ACTIVE<o:p></o:p></span></p> </td> <td style="padding: 0in 5.4pt; width: 68.15pt; height: 12.75pt;" nowrap="nowrap" valign="bottom" width="91"> <p class="MsoNormal"><span style="font-size:78%;">dbsvr<o:p></o:p></span></p> </td> <td style="padding: 0in 5.4pt; width: 48pt; height: 12.75pt;" num="" nowrap="nowrap" valign="bottom" width="64"> <p class="MsoNormal" style="text-align: right;" align="right"><span style="font-size:78%;">1<o:p></o:p></span></p> </td> </tr> <tr style="height: 12.75pt;"> <td style="padding: 0in 5.4pt; width: 82pt; height: 12.75pt;" nowrap="nowrap" valign="bottom" width="109"> <p class="MsoNormal"><span style="font-size:78%;"><o:p> </o:p></span></p> <span style="font-size:78%;"><br /></span></td> <td style="padding: 0in 5.4pt; width: 101.45pt; height: 12.75pt;" nowrap="nowrap" valign="bottom" width="135"> <p class="MsoNormal"><span style="font-size:78%;">oracle@dbsvr<o:p></o:p></span></p> </td> <td style="padding: 0in 5.4pt; width: 49pt; height: 12.75pt;" nowrap="nowrap" valign="bottom" width="65"> <p class="MsoNormal"><span style="font-size:78%;">ACTIVE<o:p></o:p></span></p> </td> <td style="padding: 0in 5.4pt; width: 68.15pt; height: 12.75pt;" nowrap="nowrap" valign="bottom" width="91"> <p class="MsoNormal"><span style="font-size:78%;">dbsvr<o:p></o:p></span></p> </td> <td style="padding: 0in 5.4pt; width: 48pt; height: 12.75pt;" num="" nowrap="nowrap" valign="bottom" width="64"> <p class="MsoNormal" style="text-align: right;" align="right"><span style="font-size:78%;">1<o:p></o:p></span></p> </td> </tr> <tr style="height: 12.75pt;"> <td style="padding: 0in 5.4pt; width: 82pt; height: 12.75pt;" nowrap="nowrap" valign="bottom" width="109"> <p class="MsoNormal"><span style="font-size:78%;"><o:p> </o:p></span></p> <span style="font-size:78%;"><br /></span></td> <td style="padding: 0in 5.4pt; width: 101.45pt; height: 12.75pt;" nowrap="nowrap" valign="bottom" width="135"> <p class="MsoNormal"><span style="font-size:78%;">oracle@dbsvr<o:p></o:p></span></p> </td> <td style="padding: 0in 5.4pt; width: 49pt; height: 12.75pt;" nowrap="nowrap" valign="bottom" width="65"> <p class="MsoNormal"><span style="font-size:78%;">ACTIVE<o:p></o:p></span></p> </td> <td style="padding: 0in 5.4pt; width: 68.15pt; height: 12.75pt;" nowrap="nowrap" valign="bottom" width="91"> <p class="MsoNormal"><span style="font-size:78%;">dbsvr<o:p></o:p></span></p> </td> <td style="padding: 0in 5.4pt; width: 48pt; height: 12.75pt;" num="" nowrap="nowrap" valign="bottom" width="64"> <p class="MsoNormal" style="text-align: right;" align="right"><span style="font-size:78%;">1<o:p></o:p></span></p> </td> </tr> <tr style="height: 12.75pt;"> <td style="padding: 0in 5.4pt; width: 82pt; height: 12.75pt;" nowrap="nowrap" valign="bottom" width="109"> <p class="MsoNormal"><span style="font-size:78%;"><o:p> </o:p></span></p> <span style="font-size:78%;"><br /></span></td> <td style="padding: 0in 5.4pt; width: 101.45pt; height: 12.75pt;" nowrap="nowrap" valign="bottom" width="135"> <p class="MsoNormal"><span style="font-size:78%;">oracle@dbsvr<o:p></o:p></span></p> </td> <td style="padding: 0in 5.4pt; width: 49pt; height: 12.75pt;" nowrap="nowrap" valign="bottom" width="65"> <p class="MsoNormal"><span style="font-size:78%;">ACTIVE<o:p></o:p></span></p> </td> <td style="padding: 0in 5.4pt; width: 68.15pt; height: 12.75pt;" nowrap="nowrap" valign="bottom" width="91"> <p class="MsoNormal"><span style="font-size:78%;">dbsvr<o:p></o:p></span></p> </td> <td style="padding: 0in 5.4pt; width: 48pt; height: 12.75pt;" num="" nowrap="nowrap" valign="bottom" width="64"> <p class="MsoNormal" style="text-align: right;" align="right"><span style="font-size:78%;">1<o:p></o:p></span></p> </td> </tr> <tr style="height: 12.75pt;"> <td style="padding: 0in 5.4pt; width: 82pt; height: 12.75pt;" nowrap="nowrap" valign="bottom" width="109"> <p class="MsoNormal"><span style="font-size:78%;"><o:p> </o:p></span></p> <span style="font-size:78%;"><br /></span></td> <td style="padding: 0in 5.4pt; width: 101.45pt; height: 12.75pt;" nowrap="nowrap" valign="bottom" width="135"> <p class="MsoNormal"><span style="font-size:78%;">oracle@dbsvr<o:p></o:p></span></p> </td> <td style="padding: 0in 5.4pt; width: 49pt; height: 12.75pt;" nowrap="nowrap" valign="bottom" width="65"> <p class="MsoNormal"><span style="font-size:78%;">ACTIVE<o:p></o:p></span></p> </td> <td style="padding: 0in 5.4pt; width: 68.15pt; height: 12.75pt;" nowrap="nowrap" valign="bottom" width="91"> <p class="MsoNormal"><span style="font-size:78%;">dbsvr<o:p></o:p></span></p> </td> <td style="padding: 0in 5.4pt; width: 48pt; height: 12.75pt;" num="" nowrap="nowrap" valign="bottom" width="64"> <p class="MsoNormal" style="text-align: right;" align="right"><span style="font-size:78%;">1<o:p></o:p></span></p> </td> </tr> <tr style="height: 12.75pt;"> <td style="padding: 0in 5.4pt; width: 82pt; height: 12.75pt;" nowrap="nowrap" valign="bottom" width="109"> <p class="MsoNormal"><span style="font-size:78%;">USER1<o:p></o:p></span></p> </td> <td style="padding: 0in 5.4pt; width: 101.45pt; height: 12.75pt;" nowrap="nowrap" valign="bottom" width="135"> <p class="MsoNormal"><span style="font-size:78%;">sqlplusw.exe<o:p></o:p></span></p> </td> <td style="padding: 0in 5.4pt; width: 49pt; height: 12.75pt;" nowrap="nowrap" valign="bottom" width="65"> <p class="MsoNormal"><span style="font-size:78%;">ACTIVE<o:p></o:p></span></p> </td> <td style="padding: 0in 5.4pt; width: 68.15pt; height: 12.75pt;" nowrap="nowrap" valign="bottom" width="91"> <p class="MsoNormal"><span style="font-size:78%;">doug-pc<o:p></o:p></span></p> </td> <td style="padding: 0in 5.4pt; width: 48pt; height: 12.75pt;" num="" nowrap="nowrap" valign="bottom" width="64"> <p class="MsoNormal" style="text-align: right;" align="right"><span style="font-size:78%;">1<o:p></o:p></span></p> </td> </tr> <tr style="height: 12.75pt;"> <td style="padding: 0in 5.4pt; width: 82pt; height: 12.75pt;" nowrap="nowrap" valign="bottom" width="109"> <p class="MsoNormal"><span style="font-size:78%;">USER1<o:p></o:p></span></p> </td> <td style="padding: 0in 5.4pt; width: 101.45pt; height: 12.75pt;" nowrap="nowrap" valign="bottom" width="135"> <p class="MsoNormal"><span style="font-size:78%;"><o:p> </o:p></span></p> <span style="font-size:78%;"><br /></span></td> <td style="padding: 0in 5.4pt; width: 49pt; height: 12.75pt;" nowrap="nowrap" valign="bottom" width="65"> <p class="MsoNormal"><span style="font-size:78%;">ACTIVE<o:p></o:p></span></p> </td> <td style="padding: 0in 5.4pt; width: 68.15pt; height: 12.75pt;" nowrap="nowrap" valign="bottom" width="91"> <p class="MsoNormal"><span style="font-size:78%;">appsvr<o:p></o:p></span></p> </td> <td style="padding: 0in 5.4pt; width: 48pt; height: 12.75pt;" num="" nowrap="nowrap" valign="bottom" width="64"> <p class="MsoNormal" style="text-align: right;" align="right"><span style="font-size:78%;">7<o:p></o:p></span></p> </td> </tr> <tr style="height: 12.75pt;"> <td style="padding: 0in 5.4pt; width: 82pt; height: 12.75pt;" nowrap="nowrap" valign="bottom" width="109"> <p class="MsoNormal"><span style="font-size:78%;">USER1<o:p></o:p></span></p> </td> <td style="padding: 0in 5.4pt; width: 101.45pt; height: 12.75pt;" nowrap="nowrap" valign="bottom" width="135"> <p class="MsoNormal"><span style="font-size:78%;">sqlplus.exe</span></p> </td> <td style="padding: 0in 5.4pt; width: 49pt; height: 12.75pt;" nowrap="nowrap" valign="bottom" width="65"> <p class="MsoNormal"><span style="font-size:78%;">INACTIVE<o:p></o:p></span></p> </td> <td style="padding: 0in 5.4pt; width: 68.15pt; height: 12.75pt;" nowrap="nowrap" valign="bottom" width="91"> <p class="MsoNormal"><span style="font-size:78%;">doug-pc<o:p></o:p></span></p> </td> <td style="padding: 0in 5.4pt; width: 48pt; height: 12.75pt;" num="" nowrap="nowrap" valign="bottom" width="64"> <p class="MsoNormal" style="text-align: right;" align="right"><span style="font-size:78%;">3<o:p></o:p></span></p> </td> </tr> <tr style="height: 12.75pt;"> <td style="padding: 0in 5.4pt; width: 82pt; height: 12.75pt;" nowrap="nowrap" valign="bottom" width="109"> <p class="MsoNormal"><span style="font-size:78%;">USER2<o:p></o:p></span></p> </td> <td style="padding: 0in 5.4pt; width: 101.45pt; height: 12.75pt;" nowrap="nowrap" valign="bottom" width="135"> <p class="MsoNormal"><span style="font-size:78%;">sqlplus.exe</span></p> </td> <td style="padding: 0in 5.4pt; width: 49pt; height: 12.75pt;" nowrap="nowrap" valign="bottom" width="65"> <p class="MsoNormal"><span style="font-size:78%;">INACTIVE<o:p></o:p></span></p> </td> <td style="padding: 0in 5.4pt; width: 68.15pt; height: 12.75pt;" nowrap="nowrap" valign="bottom" width="91"> <p class="MsoNormal"><span style="font-size:78%;">doug-pc<o:p></o:p></span></p> </td> <td style="padding: 0in 5.4pt; width: 48pt; height: 12.75pt;" num="" nowrap="nowrap" valign="bottom" width="64"> <p class="MsoNormal" style="text-align: right;" align="right"><span style="font-size:78%;">1<o:p></o:p></span></p> </td> </tr> <tr style="height: 12.75pt;"> <td style="padding: 0in 5.4pt; width: 82pt; height: 12.75pt;" nowrap="nowrap" valign="bottom" width="109"> <p class="MsoNormal"><span style="font-size:78%;">USER3<o:p></o:p></span></p> </td> <td style="padding: 0in 5.4pt; width: 101.45pt; height: 12.75pt;" nowrap="nowrap" valign="bottom" width="135"> <p class="MsoNormal"><span style="font-size:78%;">sqlplus.exe<o:p></o:p></span></p> </td> <td style="padding: 0in 5.4pt; width: 49pt; height: 12.75pt;" nowrap="nowrap" valign="bottom" width="65"> <p class="MsoNormal"><span style="font-size:78%;">INACTIVE<o:p></o:p></span></p> </td> <td style="padding: 0in 5.4pt; width: 68.15pt; height: 12.75pt;" nowrap="nowrap" valign="bottom" width="91"> <p class="MsoNormal"><span style="font-size:78%;">tony-pc<o:p></o:p></span></p> </td> <td style="padding: 0in 5.4pt; width: 48pt; height: 12.75pt;" num="" nowrap="nowrap" valign="bottom" width="64"> <p class="MsoNormal" style="text-align: right;" align="right"><span style="font-size:78%;">2<o:p></o:p></span></p> </td> </tr> <tr style="height: 12.75pt;"> <td style="padding: 0in 5.4pt; width: 82pt; height: 12.75pt;" nowrap="nowrap" valign="bottom" width="109"> <p class="MsoNormal"><span style="font-size:78%;">USER4<o:p></o:p></span></p> </td> <td style="padding: 0in 5.4pt; width: 101.45pt; height: 12.75pt;" nowrap="nowrap" valign="bottom" width="135"> <p class="MsoNormal"><span style="font-size:78%;">sqlplus.exe<o:p></o:p></span></p> </td> <td style="padding: 0in 5.4pt; width: 49pt; height: 12.75pt;" nowrap="nowrap" valign="bottom" width="65"> <p class="MsoNormal"><span style="font-size:78%;">INACTIVE<o:p></o:p></span></p> </td> <td style="padding: 0in 5.4pt; width: 68.15pt; height: 12.75pt;" nowrap="nowrap" valign="bottom" width="91"> <p class="MsoNormal"><span style="font-size:78%;">jeff-pc<o:p></o:p></span></p> </td> <td style="padding: 0in 5.4pt; width: 48pt; height: 12.75pt;" num="" nowrap="nowrap" valign="bottom" width="64"> <p class="MsoNormal" style="text-align: right;" align="right"><span style="font-size:78%;">3<o:p></o:p></span></p> </td> </tr> <tr style="height: 12.75pt;"> <td style="padding: 0in 5.4pt; width: 82pt; height: 12.75pt;" nowrap="nowrap" valign="bottom" width="109"> <p class="MsoNormal"><span style="font-size:78%;">USER5<o:p></o:p></span></p> </td> <td style="padding: 0in 5.4pt; width: 101.45pt; height: 12.75pt;" nowrap="nowrap" valign="bottom" width="135"> <p class="MsoNormal"><span style="font-size:78%;">sqlplus.exe<o:p></o:p></span></p> </td> <td style="padding: 0in 5.4pt; width: 49pt; height: 12.75pt;" nowrap="nowrap" valign="bottom" width="65"> <p class="MsoNormal"><span style="font-size:78%;">INACTIVE<o:p></o:p></span></p> </td> <td style="padding: 0in 5.4pt; width: 68.15pt; height: 12.75pt;" nowrap="nowrap" valign="bottom" width="91"> <p class="MsoNormal"><span style="font-size:78%;">ann-pc<o:p></o:p></span></p> </td> <td style="padding: 0in 5.4pt; width: 48pt; height: 12.75pt;" num="" nowrap="nowrap" valign="bottom" width="64"> <p class="MsoNormal" style="text-align: right;" align="right"><span style="font-size:78%;">2<o:p></o:p></span></p> </td> </tr> <tr style="height: 12.75pt;"> <td style="padding: 0in 5.4pt; width: 82pt; height: 12.75pt;" nowrap="nowrap" valign="bottom" width="109"> <p class="MsoNormal"><span style="font-size:78%;">USER6<o:p></o:p></span></p> </td> <td style="padding: 0in 5.4pt; width: 101.45pt; height: 12.75pt;" nowrap="nowrap" valign="bottom" width="135"> <p class="MsoNormal"><span style="font-size:78%;">sqlplus.exe<o:p></o:p></span></p> </td> <td style="padding: 0in 5.4pt; width: 49pt; height: 12.75pt;" nowrap="nowrap" valign="bottom" width="65"> <p class="MsoNormal"><span style="font-size:78%;">INACTIVE<o:p></o:p></span></p> </td> <td style="padding: 0in 5.4pt; width: 68.15pt; height: 12.75pt;" nowrap="nowrap" valign="bottom" width="91"> <p class="MsoNormal"><span style="font-size:78%;">ann-pc<o:p></o:p></span></p> </td> <td style="padding: 0in 5.4pt; width: 48pt; height: 12.75pt;" num="" nowrap="nowrap" valign="bottom" width="64"> <p class="MsoNormal" style="text-align: right;" align="right"><span style="font-size:78%;">6<o:p></o:p></span></p> </td> </tr> <tr style="height: 12.75pt;"> <td style="padding: 0in 5.4pt; width: 82pt; height: 12.75pt;" nowrap="nowrap" valign="bottom" width="109"> <p class="MsoNormal"><span style="font-size:78%;">USER1<o:p></o:p></span></p> </td> <td style="padding: 0in 5.4pt; width: 101.45pt; height: 12.75pt;" nowrap="nowrap" valign="bottom" width="135"> <p class="MsoNormal"><span style="font-size:78%;"><o:p> </o:p></span></p> <span style="font-size:78%;"><br /></span></td> <td style="padding: 0in 5.4pt; width: 49pt; height: 12.75pt;" nowrap="nowrap" valign="bottom" width="65"> <p class="MsoNormal"><span style="font-size:78%;">INACTIVE<o:p></o:p></span></p> </td> <td style="padding: 0in 5.4pt; width: 68.15pt; height: 12.75pt;" nowrap="nowrap" valign="bottom" width="91"> <p class="MsoNormal"><span style="font-size:78%;">appsvr<o:p></o:p></span></p> </td> <td style="padding: 0in 5.4pt; width: 48pt; height: 12.75pt;" num="" nowrap="nowrap" valign="bottom" width="64"> <p class="MsoNormal" style="text-align: right;" align="right"><span style="font-size:78%;">2<o:p></o:p></span></p> </td> </tr> </tbody></table> <p class="MsoNormal">The sessions with the name "oracle" in the program name are created by Oracle and not from users. In this example there are 6 users with sessions. USER1 has a total of 13 sessions (4 from doug-pc and 9 from appsvr). Of the 13 sessions, 8 sessions are active. Note the empty value for the program name for some of the USER1 sessions. These appear to be related to sessions using JBDC.<br /><br /><a href="http://download-west.oracle.com/docs/cd/B10501_01/index.htm">Oracle's online documentation</a> is an excellent source for learning more about v$session and other data dictionary tables.</p> <span style=";font-family:courier new;font-size:85%;" ><br /><br /></span>Java Manhttp://www.blogger.com/profile/06426420875519987307noreply@blogger.com0tag:blogger.com,1999:blog-24495668.post-1143133559513318012006-03-23T09:01:00.000-08:002006-03-23T09:05:59.526-08:00Using the split command to break up large files<p class="MsoNormal">The split command allows you to break up a large file into several smaller files. A file can split up based on size or lines. The split command is available on UNIX, Linux, and Windows (through <a href="http://www.cygwin.com/">Cygwin</a>). Below is an example of<span style=""> </span>a large file a user may want to split:</p><p class="MsoNormal"><o:p></o:p><br /><span style="font-family: courier new;">/cygdrive/c/temp/split> ls -l<br />total 1571886</span><o:p style="font-family: courier new;"></o:p><span style="font-family: courier new;"><br />-rw-r--r-- 1 userid group 1609611264 Mar 23 </span><st1:time style="font-family: courier new;" minute="39" hour="10">10:39</st1:time><span style="font-family: courier new;"> test.xml</span></p> <p class="MsoNormal"><o:p> </o:p>The following command will split up the file into 300 MB chunks:</p> <p style="font-family: courier new;" class="MsoNormal"><o:p></o:p>/cygdrive/c/temp/split> split -b300m test.xml<o:p></o:p><br />/cygdrive/c/temp/split> ls -lrt<o:p></o:p><br />total 3143772<o:p></o:p><br />-rw-r--r--<span style=""> </span>1 userid<span style=""> </span>group 1609611264 Mar 23 <st1:time minute="39" hour="10">10:39</st1:time> test.xml<o:p></o:p><br />-rw-r--r--<span style=""> </span>1 userid<span style=""> </span>group 314572800 Mar 23 <st1:time minute="43" hour="10">10:43</st1:time> xaa<o:p></o:p><br />-rw-r--r--<span style=""> </span>1 userid<span style=""> </span>group 314572800 Mar 23 <st1:time minute="43" hour="10">10:43</st1:time> xab<o:p></o:p><br />-rw-r--r--<span style=""> </span>1 userid<span style=""> </span>group 314572800 Mar 23 <st1:time minute="44" hour="10">10:44</st1:time> xac<o:p></o:p><br />-rw-r--r--<span style=""> </span>1 userid<span style=""> </span>group 314572800 Mar 23 <st1:time minute="44" hour="10">10:44</st1:time> xad<o:p></o:p><br />-rw-r--r--<span style=""> </span>1 userid<span style=""> </span>group 314572800 Mar 23 <st1:time minute="45" hour="10">10:45</st1:time> xae<o:p></o:p><br />-rw-r--r--<span style=""> </span>1 userid<span style=""> </span>group 36747264 Mar 23 <st1:time minute="45" hour="10">10:45</st1:time> xaf</p> <p class="MsoNormal"><o:p> </o:p><br />In this example the large file was separated into six smaller files(xaa, xab, xac, xad, xae, xaf). The length of the files names generated by split is configurable with the –a option. Note that the split command will keep the original file intact. For splitting up larger files, the verbose option is useful for monitoring progress.</p>Java Manhttp://www.blogger.com/profile/06426420875519987307noreply@blogger.com2tag:blogger.com,1999:blog-24495668.post-1143057606607771302006-03-22T11:54:00.000-08:002010-06-01T21:25:00.212-07:00Generating Java Stack Trace<p class="MsoNormal">A Java stack trace displays the current state of each thread and monitor in a Java Virtual Machine. The stack trace displays the current method being executed by a thread. In addition the trace shows the sequence of calls leading up to the execution of the current method. </p> <p class="MsoNormal"><o:p></o:p>Analyzing stack traces can be very helpful in determine the causes of run time errors. For example if there is a deadlock detected, a stack trace can be generated to determine where the hang is occurring. <o:p></o:p></p> <p class="MsoNormal"><o:p></o:p>A Java stack trace can be generated by sending a signal to the JVM. <o:p></o:p>On a UNIX environment this can be accomplished by sending a <span style="font-family:courier new;">kill -3</span> to the Java process. <o:p></o:p> It may be necessary to generate stack trace for several Java processes. The following can be used to send the kill signal to several Java processes:<o:p></o:p></p> <p class="MsoNormal"><span style="font-family:courier new;font-size:85%;">for pid in `ps -u userid | grep java | awk '{print $1}'`;</span><span style="font-size:85%;"><o:p style="font-family: courier new;"></o:p><br /></span><span style="font-family:courier new;font-size:85%;">do kill -3 $pid;</span><span style="font-size:85%;"><o:p style="font-family: courier new;"></o:p><br /></span><span style="font-family:courier new;font-size:85%;">done</span><o:p></o:p></p> <p class="MsoNormal">On Windows pressing <span style="font-family:courier new;"><ctrl><break></break></ctrl></span>the <span style="font-family: courier new;">ctrl-break</span> keys while having focus on the window where the Java process is running will generate the stack trace.<o:p></o:p></p> <p class="MsoNormal"><o:p></o:p>Sun's Java website provides an excellent article on <a href="http://java.sun.com/developer/onlineTraining/Programming/JDCBook/stack.html">analyzing stack traces</a>.<o:p></o:p></p> <p class="MsoNormal"><br /><a href="http://java.sun.com/developer/onlineTraining/Programming/JDCBook/stack.html"></a></p>Java Manhttp://www.blogger.com/profile/06426420875519987307noreply@blogger.com1tag:blogger.com,1999:blog-24495668.post-1142987727908178822006-03-21T15:33:00.000-08:002010-06-01T21:26:29.253-07:00Removing carriage returns (^M) from a file<p class="MsoNormal" style="font-family:arial;"><span style="font-size:100%;">When transferring a file from UNIX to Windows in binary mode, you may observe carriage returns (control M characters) in the file when viewing it on UNIX. The control M character(^M) is the end of line character on Windows . When you transfer afile via FTP in binary mode, the file is transferred with the carriage returns intact. The control M character is not the end of line character in UNIX, so as a result the ^M is interpreted as part of the file. In order to avoid this problem the file should be transferred in ASCII mode. If this is not possible there are scripts which can remove the Control M character. Below is an example of using the </span><span style="font-size:100%;">tr command to remove the control M characters from a file:<br /><br /></span><span style="font-size:100%;"><span style="font-family:courier new;">tr -d "\015" < $input > $output</span><br /><br /></span><span style="font-size:100%;">The tr command reads in characters from standard input and replaces or deletes characters before writing them back to standard output. The -d option in the example above will delete the carriage returns (specified in octal as o15) from the specified input file ($input) and redirect the results to an output file ($output). Here is in a for loop:</span></p><p class="MsoNormal"><span style="font-family:Arial;font-size:85%;color:navy;"><span style="font-size: 10pt; color: navy; font-family: Arial;">for f in `ls `</span></span></p> <p class="MsoNormal"><span style="font-family:Arial;font-size:85%;color:navy;"><span style="font-size: 10pt; color: navy; font-family: Arial;">do </span></span></p> <p class="MsoNormal"><span style="font-family:Arial;font-size:85%;color:navy;"><span style="font-size: 10pt; color: navy; font-family: Arial;">tr -d "\015" <$f >tmp/$f</span></span></p> <p class="MsoNormal"><span style="font-family:Arial;font-size:85%;color:navy;"><span style="font-size: 10pt; color: navy; font-family: Arial;">done</span></span></p> <p class="MsoNormal"><span style="font-family:Arial;font-size:85%;color:navy;"><span style="font-size: 10pt; color: navy; font-family: Arial;"> </span></span></p><br /><br /><br /><span class="Text"></span>Java Manhttp://www.blogger.com/profile/06426420875519987307noreply@blogger.com0tag:blogger.com,1999:blog-24495668.post-1142982457152694312006-03-21T15:05:00.000-08:002006-03-21T15:07:37.163-08:00I Did Not Know ThatWelcome to I Did Know That. This is the blog where I will tell you everything I dont know. This may take a while. Enjoy !Java Manhttp://www.blogger.com/profile/06426420875519987307noreply@blogger.com0