How to take MySQL database dump:
mysqldump -hhostname-uusername -ppassword schemaname tablename (contents will be printed on the console)
mysqldump -hhostname -uusername -ppassword schemaname tablename> filename (contents will be written on file)
hostname: name of the host. If the db is on your local system, then this might not be needed
schemaname: name of the schema which you want to back up
tablename: name of the table which you want to back up
filename: name of the file which will hold the dump. You can specify the location of the file too. Eg. C:\sql\testsqldump.sql. If 'sql' directory doesn't exist and error will be generated.
eg. mysqldump -uroot -padmin userinfo_schema USER_TABLE > D:\sql\userinfo.sql
If you don't provide the tablename, then the dump of whole schema will be taken.
To take dump of all the schema
mysqldump -uroot -padmin --all-databases > filename
To populate the MySQL database:
mysql -uusername -ppassword schemaname < filename
filename: name of the file that contains the mysqldump
eg. mysql -uroot -padmin userinfo_schema < D:\sql\userinfo.sql
Sunday, August 31, 2008
Thursday, July 31, 2008
TaF Public release
We are now releasing Tell-A-Friend widget for public use.
One of the features that makes this widget stand apart from rest of the widgets is that, if you wish to change the design of the buttons (be it the color, size or appearance), you don't have to embed a new or modified code in your webpage/blog. This helps save a lot of copy-paste exercise, which is kinda a welcome feature for lazy bums like me. All one has to do it to go to the accounts page, choose the kinda button they like, save the changes and then its all Eureka. All the changes are instantly reflected in the blogsite/webpage where TaF is embedded. Now, isn't this something cool ??
Apart from wiring a few connectors in the TaF widget, I worked on the analytics collection module. This was a pretty good learning exercise. I got to know more about the Apache log4j utility. These Apache guys are real bonds. They write some pretty good stuff.
For analytics collections, I wrote a custom JDBC appender to log all data. This has many advantages.
1) It consumes only a limited database connections.
2) Requests are served on first-come-first-serve basis. So, everything is sequential in nature in accordance to time. (log4j uses a queue)
But then, there are possible pitfalls too !!
Imagine that there are many requests, this will increase the queue size, thus increasing the response time. As of now, we have tested our infrastructure for traffics much more than we are expecting. If anyhow, response time does gets a beating, switching to a distributed system would be a possible solution which I suppose would require a bit of tweaking.
May be I will soon write another post on how to write custom JDBC appender and on analytics collection framework of works.
One of the features that makes this widget stand apart from rest of the widgets is that, if you wish to change the design of the buttons (be it the color, size or appearance), you don't have to embed a new or modified code in your webpage/blog. This helps save a lot of copy-paste exercise, which is kinda a welcome feature for lazy bums like me. All one has to do it to go to the accounts page, choose the kinda button they like, save the changes and then its all Eureka. All the changes are instantly reflected in the blogsite/webpage where TaF is embedded. Now, isn't this something cool ??
Apart from wiring a few connectors in the TaF widget, I worked on the analytics collection module. This was a pretty good learning exercise. I got to know more about the Apache log4j utility. These Apache guys are real bonds. They write some pretty good stuff.
For analytics collections, I wrote a custom JDBC appender to log all data. This has many advantages.
1) It consumes only a limited database connections.
2) Requests are served on first-come-first-serve basis. So, everything is sequential in nature in accordance to time. (log4j uses a queue)
But then, there are possible pitfalls too !!
Imagine that there are many requests, this will increase the queue size, thus increasing the response time. As of now, we have tested our infrastructure for traffics much more than we are expecting. If anyhow, response time does gets a beating, switching to a distributed system would be a possible solution which I suppose would require a bit of tweaking.
May be I will soon write another post on how to write custom JDBC appender and on analytics collection framework of works.
Labels:
me,
pramati,
products,
projects,
tell-a-friend,
web development
Friday, May 30, 2008
Tell-a-Friend
Tell-a-Friend or TaF (as we developers call it) is a new product from Pramati Technology, Hyderabad
Its something to aid 'spread the word around the world'. Just click on it and instantly announce things to your near & dear ones. So, you can announce your blog posts, articles, products on sale etc. through IM, Email, Blogs and Social Networks(like Facebook and Twitter) through a single integrated interface. So, its kinda like a single window to multiple channels to make a million announcements. So, it will bring more clicks to your weblog / website and help market your articles/products.
When Sunny showed me the TaF button embedded in Nina's blog (ya...thats our test blog), I could see foretell that this product could actually become a rage. Intel Mashmaker, CatchFlix and BigScreen are already using it/used it. But, now any one can integrate TaF in their website/blog for the following 2 divine reasons:
1) The free version is absolutely free :P (and one day beer shall also be free)
2) All it takes is embedding a code snippet in the page where the TaF icon is to be displayed.
Hope I see the TaF icons weblogs alongside dig.com, stumble upon etc. icons. After all, it always feels nice to see people use and talk about something that has your code :P.
TaF extensively employs JAVA, JAVASCRIPT, DOJO and AJAX. The widget opens up in an iframe and seemlessly gives a web2.0 feel to the page. We are working to further boost its performance by using CSS sprites, decreasing the number of http request/response and fine-tuning the backend. A rework on its look-and-feel is also being undertaken. So, with time, its gonna become all the more difficult to ignore it and impossible to resist not having it on your page :)
Its something to aid 'spread the word around the world'. Just click on it and instantly announce things to your near & dear ones. So, you can announce your blog posts, articles, products on sale etc. through IM, Email, Blogs and Social Networks(like Facebook and Twitter) through a single integrated interface. So, its kinda like a single window to multiple channels to make a million announcements. So, it will bring more clicks to your weblog / website and help market your articles/products.
When Sunny showed me the TaF button embedded in Nina's blog (ya...thats our test blog), I could see foretell that this product could actually become a rage. Intel Mashmaker, CatchFlix and BigScreen are already using it/used it. But, now any one can integrate TaF in their website/blog for the following 2 divine reasons:
1) The free version is absolutely free :P (and one day beer shall also be free)
2) All it takes is embedding a code snippet in the page where the TaF icon is to be displayed.
Hope I see the TaF icons weblogs alongside dig.com, stumble upon etc. icons. After all, it always feels nice to see people use and talk about something that has your code :P.
TaF extensively employs JAVA, JAVASCRIPT, DOJO and AJAX. The widget opens up in an iframe and seemlessly gives a web2.0 feel to the page. We are working to further boost its performance by using CSS sprites, decreasing the number of http request/response and fine-tuning the backend. A rework on its look-and-feel is also being undertaken. So, with time, its gonna become all the more difficult to ignore it and impossible to resist not having it on your page :)
Monday, January 21, 2008
JSON and HashMap
DWR is used for easy 'AJAX for JAVA' and is employed to call Java methods from Javascript (version 2.0 + supports reverse-AJAX too).
Working on the ShopprStream(earlier known as WEB122) has helped me get acquainted with many facets of web-development.
Now I have a Java method that returns a generic HashMap object ;
For this example lets consider that the key is of type String
And the elements are instances of the class CustomClass with name (of type String) as instance variable
The DWR call will return a JSON object. This is how we can access the dat a
If the HashMap contains custom objects, make sure it has a corresponding converter entry in the dwr.xml file
for example, if my class is called CustomClass, then write as
<convert converter="bean" match="com.pramati.web122.imsupport.ContactDetail"/>
Here, abc.xyz is the package structure
If object returned is hashmap, then values can be accessed as:
hasMap[key]
If object returned is hashmap, then values can be accessed as:
hasMap[key][0], hasMap[key][1], hasMap[key][2] . . . . .
Working on the ShopprStream(earlier known as WEB122) has helped me get acquainted with many facets of web-development.
Now I have a Java method that returns a generic HashMap object ;
For this example lets consider that the key is of type String
The DWR call will return a JSON object. This is how we can access the dat
for (var key in hashMap)
{
//if not using Firebug, comment out console.log statements
//'key' is the key in the HashMap
console.log("key : "+ key);
//this will give the no. of elements stored corresponding to the 'key'
console.log("hashMap[key].length: "+ hashMap[key].length);
//Access individual elements corresponding to the 'key'
for(var i=0; i<hashMap[key].length; i++)
{
console.log("hashMap[key][i].name: " + hashMap[key][i].name);
}
}
If the HashMap contains custom objects, make sure it has a corresponding converter entry in the dwr.xml file
Here, abc.xyz is the package structure
If object returned is hashmap
hasMap[key]
hasMap[key][0],
Labels:
AJAX,
HTML,
Java,
JavaScript,
newbie blues,
programming,
web development
Thursday, January 17, 2008
Helpful JavaScripts
To bring focus to a text box / button or any other element
just add this javascript in the HTML code:
for example, the following code will bring focus to the textbox that has the id email
just add this javascript in the HTML code:
where elementId the id of the element on which the focus is to be set
<script type="text/javascript">
document.getElementById("elementId").focus();
</script>
for example, the following code will bring focus to the textbox that has the id email
<input type="text" id="email" />
<script type="text/javascript">
document.getElementById("email").focus();
</script>
Wednesday, December 5, 2007
Fake Mail
One can send mails using JAVA Mail API. It is fairly simple to use this library to send mails.
First download the JAVA Mail API, and add mail.jar to your classpath
Then download, JAF API, and add activation.jar to your classpath
Following is the simple code:
Java Class: TestMail.java
WARNING:
When full headers are viewed by the recepeint for a mail sent by this program, it mite have an indication that there is something fishy about how the mail was sent !!
Happy Spamming !!!
First download the JAVA Mail API, and add mail.jar to your classpath
Then download, JAF API, and add activation.jar to your classpath
Following is the simple code:
Java Class: TestMail.java
import java.io.*;
import java.util.Properties;
import java.util.Date;
import javax.mail.*;
import javax.mail.internet.*;
import java.net.InetAddress;
class TestMail
{
public static void main(String args[])
{
try
{
//from address
String from = "fromaddress@somecompany.com";
//receipents of the mail
String to = "toaddress@someothercompany.com";
/*
*If there are multiple
*recepients, then email ids
*should be stored in a String
*with a space in between them.
*eg: String to = "id1@comp1.com id2@comp2.com id3@comp3.com"
*/
//subject of the mail
String subject = "Test Mail Subject";
//e-mail content
String text = "This is a test email";
/*SMTP host
*SMTP host should be correct
*for this program to work.
*Also, some SMTP servers
*are configured to allow
*messages to be sent from
*one or a few doamins
*/
String mailhost = "mail.somecompany.com";
//mailer
String mailer = "testmailer";
Properties props = System.getProperties();
props.put("mail.smtp.host", mailhost);
Session session = Session.getInstance(props, null);
//construct the message
Message msg = new MimeMessage(session);
msg.setFrom(new InternetAddress(from));
msg.setRecipients(Message.RecipientType.TO,
InternetAddress.parse(to, false));
msg.setSubject(subject);
msg.setText(text);
msg.setHeader("X-Mailer", mailer);
msg.setSentDate(new Date());
//send the mail
Transport.send(msg);
System.out.println("\nMail was sent successfully.");
}
catch(Exception e)
{
e.printStackTrace();
}
}
}
WARNING:
When full headers are viewed by the recepeint for a mail sent by this program, it mite have an indication that there is something fishy about how the mail was sent !!
Happy Spamming !!!
Tuesday, December 4, 2007
JavaScript NULL
For JavaScript:
If you want to test whether a String object is NULL , then the following may FAIL
if(someString == "")
if(someString == "null")
The CORRECT way to test would be:
if(someString == null)
---------------------------------------------------------
Resources:
http://lists.evolt.org/archive/Week-of-Mon-20050214/169524.html
If you want to test whether a String object is NULL , then the following may FAIL
if(someString == "")
if(someString == "null")
The CORRECT way to test would be:
if(someString == null)
---------------------------------------------------------
Resources:
http://lists.evolt.org/archive/Week-of-Mon-20050214/169524.html
Subscribe to:
Posts (Atom)