Friday, July 8, 2011

Get the Disk Usage Statistics from the WinDirStat !

WinDirStat is an opensource tool to identify howmuch of disk space you are using on your wondow box. It shows disk, file and directory sizes in a treelist as well as graphically in a treemap, much like KDirStat or SequoiaView.

Once i started using it, i feel like life would have been very hard without it.
Why don't you try it yourself.

You can download the tool from http://windirstat.info/

Read More...

Wednesday, June 29, 2011

How to parse multi value parameter from SSRS Report !

While writing an SSRS Report, I had to parse a multivalued parameter and stored it on a temp table. After some googling i came up with the following solution. @id is the multi valued parameter that need to be parsed. Following is the sample code that you can used to parse and put the values on a temp table.


-- @uid is the parameter. Lets define the parameter for testing.

declare @uid as nvarchar(200)
set @uid='u01052901,u01052789,u01052897,u0105345,u08023432,u0234324,u23479879'

create table #TempIDTable (
slice varchar(50))
declare @index1 int
declare @u_id nvarchar(4000)
set @index1 = 1
if @uid is null
set @index1 = 0
while @index1 !=0
begin
set @index1 = charindex(',',@uid)
if @index1 !=0
set @u_id = left(@uid,@index1 - 1)
else
set @u_id = @uid
insert into #TempIDTable select @u_id
set @uid= right(@uid,len(@uid) - @index1)
if len(@uid) = 0
break
end

Select * from #TempIDTable
--drop table #TempIDTable

Read More...

Friday, June 17, 2011

Date Conversion from YYYY-MM-DD HH:MM:SS:MMM to YYYY-MM-DD 00:00:00:000 !

Just keeping it handy !

declare @StartTime as DateTime
set @StartTime= dateadd(dd,0, datediff(dd,0,'2011-06-08 11:18:26.000'))
select @StartTime as StartTime


Read More...

Tuesday, March 23, 2010

Schema Spy, A Graphical Database Schema Metadata Browser.

Schemaspy is a java based tool that analyzes the metadata of a schema in a database and generated the visual representation of it. The output is highly user friendly. You can browse through table via child and parent table relationship.

Schema Spy uses the dot executable from graphviz to generate the graphical representation of the schema and its relationship. Graphviz is the graphics visualization software that takes descriptions of graphs in a simple text language, and make diagrams in several useful formats such as images and SVG for web pages, Postscript for inclusion in PDF or other documents; or display in an interactive graph browser.

Following is the steps to execute the SchemaSpy tool (for a sample MYSQL database.)
1. Download and install Graphviz from http://www.graphviz.org/Download..php
2. Download the Schema spay jar file, Schemaspy_x_y_z.jar from http://sourceforge.net/projects/schemaspy/files/
3. Download the corresponding JDBC Connector and have it on the same source folder where the schemaspy_x_y_z.jar resides. For example for a mysql database, I would simply download mysql-connector-java-5.1.5.jar or any other latest version of mysql connector.
4. Now from the source location of your Schemaspy_x_y_z.jar file, execute schemaspy to generate the graphical representation of the schema of your database, as shown on the following syntax

java -jar schemaSpy_x.y.z.jar -t database_type -dp mysql jdbcdatabase_connector -hq -o output_Directory -db databaseName -u username -p password
for example : java -jar schemaSpy_4.1.1.jar -t mysql -dp mysql-connector-java-5.1.5.jar -hq -o out -db bisudatabae -u bishow -p north


Read More...

Friday, January 22, 2010

Converting Clob Datatype to String and ViceVersa .

If you have been using Hibernate 3.x.x or greater you can easily convert clob type to string type and vice versa, i.e String data type to Clob type.

Following piece of codes demonstrate the process of doing the conversion.


.........
.........

Clob textClobValue;
String textValue;
String newTextValue;
Clob newTextClobValue;
InputStream textStream;
Paragraph paragraph // my domain Class that contains a clob datatypes and used to update the database connection with hibernate connection (Hibernate version >=3.0)
...........
...........

textClobValue=paragraph.getText();
textStream = textClobValue.getAsciiStream(); //return inputstream
textValue=convertStreamToString(textStream);
newTextValue=textValue.replaceAll("Some text","new Text"); //Replacing some text from old text.

newTextClobValue=Hibernate.createClob(newTextValue);
//System.out.println("Updated="+newParaContentValue);
paragraph.setText(newTextClobValue);
..........
..........
..........



public static String convertStreamToString(InputStream is) throws Exception {
BufferedReader reader = new BufferedReader(new InputStreamReader(is));
StringBuilder sb = new StringBuilder();
String line = null;

while ((line = reader.readLine()) != null) {
sb.append(line + "\n");
}
is.close();
return sb.toString();
}




Read More...

Tuesday, November 3, 2009

Converting Groovy Array type to Java Array Type

Following is the code snipped in groovy that demonstrate the conversion Groovy Array type to Java Array Type.
Code for Groovy

def param=[]
param+="paramater 1"
param+="paramater 2"
param+="paramater 3"
param+="paramater 4"
def stringArgForJava = (String[])params


Test.callJavaClass(stringArgForJava) //static method


The sample java class is as follow;

class Test
{
public static void callJavaClass(String[] arg)
{
for(int i=0;i {
System.out.println("params "+i ":" +params[i]);
}

}
}








Read More...

Tuesday, October 13, 2009

Read a variable defined on the config file from a controller in a grail application



Let's say, you have the config.groovy file as follow.


...........
..........

environments {
production {
myVariable1="I am variable1 on RPOD"
myVariable1="I am variable1 on RPOD"
}



development {
myVariable1="I am variable1 on DEV"
myVariable1="I am variable1 on RPOD"
}

log4j {
appender.stdout = "org.apache.log4j.ConsoleAppender"
.........
........

Now the above varaible can be easily access through any of the controller as follow.


def config = ConfigurationHolder.config
def myVaraible1 = config.myVaraible1
def myVaraible2 = config.myVaraible2



Read More...

Pages

 ©mytechtoday.com 2006-2010

TOP