Thursday, 13 November 2014

JavaScript to get user typing event for chat programs

<script type="text/javascript" language="javascript">
var timer = 0;
function reduceTimer(){
timer = timer - 1;
isTyping(true);
}
function isTyping(val){
if(val == 'true'){
document.getElementById('typing_on').innerHTML = "User is typing...";
}else{

if(timer <= 0){
document.getElementById('typing_on').innerHTML = "No one is typing -blank space.";
}else{
setTimeout("reduceTimer();",500);
}
}
}
</script>

<label>
<textarea onkeypress="isTyping('true'); timer=5;" onkeyup="isTyping('false')" name="textarea" id="textarea" cols="45" rows="5"></textarea>
</label>
<div id="typing_on">No one is typing -blank speace.</div>

Friday, 21 December 2012

oracle query to export data


Oracle query to export data to a text file separated by spaces

unload sqlfile=e:\temp\tables\unload_jobs.sql 
datafile=e:\temp\tables\jobs_part2.txt 
delimiter="," quote="chr(34)" 
header=y;

Export data from mysql database


Export the data from MySql database to a text file .

SELECT * INTO OUTFILE "G:\file.txt"
      FIELDS TERMINATED BY '\t'
      LINES TERMINATED BY '\n'
FROM test.country;

Monday, 20 August 2012

copy table values of one database to another database

consider you are having two databases

Eg:  db-sample   and db-sample1

These two databases have the same  table  Student


The database of db-sample with table Student has 1000   records  and the table of Student in db-sample1
needs all those records

we can use the following query

First  set db-sample database as default Schema

Query

insert into Student SELECT * FROM `db-sample`.Student

where

Student - It is the table name of the dabase db-sample1

Student It is the table name of the dabase  db-sample


Monday, 16 July 2012

create a property file in java


       

            Properties prop = new Properties();
                   
            prop.setProperty("connectionurl", connectionurl);
            prop.setProperty("username", userName);
       
            prop.setProperty("password", passWord);
            prop.setProperty("driverClassName", driverClassName);
         
            //save properties to project root folder
            File file = new File(System.getProperty("user.dir") + File.separator +  "config.properties");
            prop.store(new FileOutputStream(file, false), null);

   This is used to create a property file with the above parameters
   connectionurl,username,password,driverClassName,.


   

create a new folder in java

 String desktopPath = System.getProperty("user.home") + File.separator + "Desktop" + File.separator + "NW Folder";

 File folder = new File(desktopPath);

if(!folder.exists())
{
      folder.mkdirs();
}

A new folder with name (NW Folder ) will be created if there is no folder in the given name specified.

Folder within folder also can be created with this .

To get the current directory in java

To get the location of Desktop
System.getProperty("user.home");

To get the location of the current working project directory
System.getProperty("user.dir");