|
JAVA and SQL Connection :-------------------------------------------------------------------- Publicize Yourself ... Free!!! Saalram.com -------------------------------------------------------------------- Java can do anything. Most of the realtime applications uses databases and they do connections via Java also. Let me explain how to make sql connection with java and an example. First Import java.sql to get access to sql classes/methods. "import java.sql.*; "Next need to identify the sql driver. Here i have used MySQL driver. " Class.forName("com.mysql.jdbc.Driver"); "Then make sql connection with the help of driver manager. "Connection con= DriverManager.getConnection("jdbc:mysql://hostname/DB Name","DBUsername","DBPassword"); " So we connected to DB now. Why do we need to connect database? It could be because to fetch/insert some sort of data into it. Let try to fetch some records from DB here. So i have to write a "select" query to get the appropriate data? Then we have to execute that query from java. It can be possible with statement objects. Using statement objects we can execute the composed query to get result set. " Statement stmt=con.createStatement(); ResultSet rs=stmt.executeQuery("select Name,placeOfBirth,Batch from trainees_Details where traineeid='123';"); " So the result set will have details of the trainee id 123. This is how we can make sql connection to fetch/get data from database. File : SqlConnect.javaimport java.sql.*; public class SqlConnect { public static void main(String[] args){ try { Class.forName("com.mysql.jdbc.Driver"); } catch(ClassNotFoundException cnfe) { System.out.println("Driver not found"+cnfe); } try { Connection con= DriverManager.getConnection ("jdbc:mysql://hostname/DB Name","DBUsername","DBPassword"); Statement stmt=con.createStatement(); ResultSet rs=stmt.executeQuery("select Name,placeOfBirth,Batch from trainees_Details where traineeid='123';"); while(rs.next()) { String nam=rs.getString("Name"); String place=rs.getString("placeOfBirth"); String batch=rs.getString("Batch"); System.out.println(nam+" "+place+""+batch); } con.close(); } catch(SQLException sqle) { System.out.println("Data base Error"+sqle); } } } ======================= Publicize Yourself... Free!http://saalram.com ========================
Place twitter on your site : JqueryJquery makes developer work easy and simple. Ok! Lets see how can we put twitter on our sites using jquery widget. We have to do nothing other than initializing the twitter account. Lets try in a simple HTML. 1. Create a " Twitter_Saalram.html" 2. Download the twitter widget pack. 3. Unzip and find "jquery.tweet.js." and "jQuery.js". 4. Now include these supporting library files on your HTML template. I mean place " <script language="javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.1/jquery.min.js" type="text/javascript"></script> <script language="javascript" src="/tweet/jquery.tweet.js" type="text/javascript"></script> " code inside <head> tag. 5. " <script type='text/javascript'> $(document).ready(function(){ $(".tweet").tweet({ username: "saalram", join_text: "auto", avatar_size: 32, count: 3, auto_join_text_default: "we said,", auto_join_text_ed: "we", auto_join_text_ing: "we were", auto_join_text_reply: "we replied to", auto_join_text_url: "we were checking out", loading_text: "loading tweets..." }); }); </script> " initialize your twitter account using the above snippet and that also should be placed in <head> tag. 6. So here we initialized twitter account and it is ready to show saalram's tweets on "Twitter_Saalram.html" page. 7. As per the above steps, Jquery will get saalram's tweets but where will it display on "Twitter_Saalram.html"? so we have to mention placeholder for saalram's tweets on our "Twitter_Saalram.html" like this in <body> part " <div class="tweet"></div> " 8. Style with our stylesheet in <head>, or modify as you like! <link href="jquery.tweet.css" media="all" rel="stylesheet" type="text/css"/> 9. Licensed under the MIT10. Read more ... ====================== Publicize Yourself... Free! http://saalram.com======================
RSS was designed to show selected data. Without RSS, users will have to check your site daily for new updates. This may be too time-consuming for many users. With an RSS feed (RSS is often called a News feed or RSS feed) they can check your site faster using an RSS aggregator (a site or program that gathers and sorts out RSS feeds). RSS data is small and fast-loading pages ==================== Publicize yourself ... Free! http://saalram.com ====================
Very simple. "Date()" function will return current date. Just try this example. File : Date_JS.html <html> <body> <script type="text/javascript"> document.write(Date()); </script> </body> </html> ==================== Publicize yourself ... Free! http://saalram.com ====================
Do free advertisement on this blog! Offer till 30thJan10. Hurry!!! http://saalram.blogspot.com
Saalram may help you to, - Publicize yourself to the world with free of cost.
- Quantify your publicity with Saalram.
- Compose your own profile link and use anywhere.
- Collaborate with others.
- Bring your business high.
- Make out the world trend.
- Probe the people.
- Analyse yourself.
Just post few words about your business and get millions of audience in a second. ============================ Publicize yourself ... Free!http://saalram.com============================
Just visit the following sites, http://saalram.comhttp://saalram.blogspot.com====================== Publicize yourself ... Free! http://saalram.com======================
Read this blog to learn "How to make money online? " http://moneymakerinfo.blogspot.com/======================= Publicize yourself ... Free! http://saalram.com=======================
Earn money from our daily tweets. Need to do nothing. Just sign up with with twitter account and start earning from your tweets. Click here to sign up http://bit.ly/81Zj9B ======================= Publicize yourself ... Free!http://saalram.com=======================
Earn money from our daily tweets. Need to do nothing. Just sign up with with twitter account and start earning from your tweets. Click here to sign up http://bit.ly/62iYYc ======================= Publicize yourself ... Free!http://saalram.com=======================
How to disable or enable drop down list in JavaScript? Just create a dropdown list in html form and have an id (mySelect) for that. Do control of the drop down list in javascript function using the id. " document.getElementById("mySelect").disabled=true; " it means disable the dropdown list and " document.getElementById("mySelect").disabled=false; " means enable. File : DisableorEnable_JS.html <html> <head> <script type="text/javascript"> function disable() { document.getElementById("mySelect").disabled=true; } function enable() { document.getElementById("mySelect").disabled=false; } </script> </head> <body> <form> <select id="mySelect"> <option>Apple</option> <option>Pear</option> <option>Banana</option> <option>Orange</option> </select><br /><br /> <input type="button" onclick="disable()" value="Disable list"> <input type="button" onclick="enable()" value="Enable list"> </form></body> </html> ======================= Publicize yourself ... Free! http://saalram.com=======================
How to change an image on button click event in javascript ? A simple and easy example given here. "compman.gif" is my default image and i get the same when i open my application. But i would like give facility to the user to change image on button click event at run time. This is how we can change an image on button click "document.getElementById("myImage").src="hackanm.gif";" . What is code is doing here is nothing but changing the image url from "compman.gif" to "hackanm.gif".Just try.! File : ChangeImage_JS.html <html> <head> <script type="text/javascript"> function changeSrc() { document.getElementById("myImage").src="hackanm.gif"; } </script> </head> <body> <img id="myImage" src="compman.gif" width="107" height="98" /> <br /><br /> <input type="button" onclick="changeSrc()" value="Change image"> </body> </html> ======================= Publicize yourself ... Free!http://saalram.com =======================
How to zoom in/out an image using JavaScript? Just simple. We have to reset the image width and height at runtime. So onclick of an image it will appear as big. Just like zooing in. Zoom out is also in this same way. In this example i have placed an image with img id "compman" with width="107" height="98". So it appears as it is when we run the application. Next on click of button " <input type="button" onclick="changeSize()" value="Change height and width of image"> " calling "changeSize()" function to reset the image size at run time. This is how i am resetting image size in "document.getElementById("compman").height="250"; document.getElementById("compman").width="300"; " in chageSize() function. Whenever we click on the button image will appear little big and it gives zoom in effects to the user. Ditto same for zoom out also. File : Zoom_JS.html <html> <head> <script type="text/javascript"> function changeSize() { document.getElementById("compman").height="250"; document.getElementById("compman").width="300"; } </script> </head>
<body> <img id="compman" src="compman.gif" width="107" height="98" /> <br /><br /> <input type="button" onclick="changeSize()" value="Change height and width of image"> </body>
</html>
====================== Publicize yourself ... Free!http://saalram.com======================
How to do Auto Jumb between text boxes in JavaScript ? Given example baptize you clearly how to implement jump from one text box to another automatically when one gets filled. Here i have 3 text boxes and plannig to get 3,2,3 charecters in textbox1,2,3 respectivley from the user. It is the best way to do validation and navigating/jumping to the next boxes automatically when the boxes filled. In this following form user can enter 3 charecters in first box and it will jump to second box automatically when first box filled with 3 chareccters. Same way 2 box will expect 2 charecters from the user and it will jump to third when 2nd box filled with two charecters. You can use the given exaple code, Wherever you need the user to jump automatically between text boxes. For example, forms getting license key,bank account number,date of birth,ticket number,railway reservation,Family card number,PAN number,Passport number,Purchase order number etc., File : AutoJump_JS.html <html> <head> <script type="text/javascript"> function checkLen(x,y) { if (y.length==x.maxLength) { var next=x.tabIndex; if (next<document.getElementById("myForm").length) { document.getElementById("myForm").elements[next].focus(); } }} </script> </head> <body> <p>This script automatically jumps to the next field when a field's maxlength has been reached:</p> <form id="myForm"> <input size="3" tabindex="1" maxlength="3" onkeyup="checkLen(this,this.value)"> <input size="2" tabindex="2" maxlength="2" onkeyup="checkLen(this,this.value)"> <input size="3" tabindex="3" maxlength="3" onkeyup="checkLen(this,this.value)"> </form> </body> </html>
================================================================================================================================== ==================================================================================================================================
How to do email, name and age validation in JavaScript? In this below example we validating three fields such as Name,Age and Email. First checking whether the given email id has symbols "@" and "." (dot). Because all emails will have . and @ to represent domain and user belongs to. For example " example@gmail.com" . So we an email id will have both "@" and "." symbol. We can assume that an email id without "@" and "." is invalid. It would better if we check charlength before @ symbol also. Obviously Age shoul be a number and between 1 to 100. This is how we validating age should not be greater than 100. Same way validating first name also. In my example i just validating that firstname must be less than 10 charecters. We can do it as we need. File : EmailValidate_JS.html <html> <head> <script type="text/javascript"> function validate(){ var at=document.getElementById("email").value.indexOf("@"); var dot=document.getElementById("email").value.indexOf("."); var age=document.getElementById("age").value; var fname=document.getElementById("fname").value; submitOK="true"; if (fname.length>10) { alert("The name must be less than 10 characters"); submitOK="false"; } if (isNaN(age)||age<1||age>100) { alert("The age must be a number between 1 and 100"); submitOK="false"; } if (at==-1) { alert("Not a valid e-mail!"); submitOK="false"; } if (dot==-1) { alert("Not a valid e-mail!"); submitOK="false"; } if (submitOK=="false") { return false; } } </script> </head> <body> <form action="validationresult.html" onsubmit="return validate()"> Name (max 10 chararcters): <input type="text" id="fname" size="20"><br /> Age (from 1 to 100): <input type="text" id="age" size="20"><br /> E-mail: <input type="text" id="email" size="20"><br /> <br /><input type="submit" value="Submit"> </form> </body> </html> ====================== Publicize yourself ... Free! http://saalram.com ======================
Get your own profile link and access it from anywhere.
Just register in " saalram" and login.
Saalram.com --> Login --> Settings --> Profile --> Set your profile link (Free)
You can embed this link any where. No ads No restrictions on your profile page. Just Try!
Link will show 100% your profiles and photo only!!! No ads !!! ======================= Publicize Yourself... Free! http://saalram.com=======================
When you place your private Ad in " saalram.blogspot.com" Rs.Zero is what you have to pay. It is so easy to place your add here. Just drop a mail to " saalram.service@gmail.com". ==================== Publicize yourself ... Free! http://saalram.com====================
Simple and useful AIR application to generate web icons. Icon Generator is a little application that lets you generate a CS3 or Web 2.0 style icon, only 3 step. Pick color, type characters, and save it. ==================== Publicize yourself ... Free! saalram.com====================
- JavaScript can put dynamic text into an HTML page - A JavaScript statement like this: document.write("<h1>" + name + "</h1>") can write a variable text into an HTML page .
- JavaScript can react to events - A JavaScript can be set to execute when something happens, like when a page has finished loading or when a user clicks on an HTML element .
- JavaScript can read and write HTML elements - A JavaScript can read and change the content of an HTML element .
- JavaScript can be used to validate data - A JavaScript can be used to validate form data before it is submitted to a server. This saves the server from extra processing .
- JavaScript can be used to detect the visitor's browser - A JavaScript can be used to detect the visitor's browser, and - depending on the browser - load another page specifically designed for that browser .
- JavaScript can be used to create cookies - A JavaScript can be used to store and retrieve information on the visitor's computer.
==================== Publicize yourself ... Free! saalram ====================
I have an example explained here to show how "getElementById" is used in JavaScript. Write me ( saalram.service@gmail.com) if you find difficult here. File : GetElement_JS.html <html> <head> <script type="text/javascript"> function alertId() { var txt="Id: " + document.getElementById("myButton").id; txt=txt + ", type: " + document.getElementById("myButton").type; txt=txt + ", value: " + document.getElementById("myButton").value; alert(txt); document.getElementById("myButton").disabled=true; } </script> </head> <body> <form> <input type="button" value="Click me!" id="myButton" onclick="alertId()" /> </form> </body> </html> ==================== Publicize yourself ... Free! saalram====================
Saalram ( http://saalram.com ) is - An innovative way to publicize yourself to the world.
- An excellent medium to let the world know about you.
- An elegant mode to announce your words to the world.
In Short, - "Publicize yourself …"
- "Let the world know you"
- "Your words to the world"
Saalram help you to, - Publicize yourself to the world with free of cost.
- Quantify your publicity with Saalram.
- Compose your own profile link and use anywhere.
- Collaborate with others.
- Bring your business high.
- Make out the world trend.
- Probe the people.
- Analyse yourself.
Who can use " saalram.com" ? Experts Publicize your skills and let the world wonder you. Youngsters Do learn, love, romance, chat, share and amaze others. Find jobs and friends. Professionals Present yourself in short and impress the people. Innovators Let the people know about your innovations in a quick way. Businessmen Advertise here and get live comments. Others Publicize yourself, Make an announcement, Find friends, Compose your profile, Meet experts, Learn, Teach, Collaborate with others, and always know "What is new? And who is doing what? " . An IT concern Saalram is a raising IT concern predominantly focusing on - Research and Innovations
- IT Services
- Business Solutions
Saalram located in India and founded at January 2009 and launched its first product on January 2010. -- ==================== Publicize yourself ... Free! Saalram ====================
"document.getElementById("myCheck").checked=true;" will get the check box value when it is checked/clicked. "document.getElementById("myCheck").checked=false;" will get the check box value when it is unchecked. Write me if you have find any issues. File : CheckBox_JS.html <html> <head> <script type="text/javascript"> function check() { document.getElementById("myCheck").checked=true; } function uncheck() { document.getElementById("myCheck").checked=false; } </script> </head> <body> <form> <input type="checkbox" id="myCheck" /> <input type="button" onclick="check()" value="Check Checkbox" /> <input type="button" onclick="uncheck()" value="Uncheck Checkbox" /> </form> </body> </html> ==================== Saalram Publicize yourself ... Free! http://saalram.com ====================
Just a single line will tell you which mouse (right or left) button is clicked. "event.button" will return "1" if right mouse button is clicked . In the same way,"event.button" will return "2" if left mouse button is clicked . File : Mouse_Click_JS.html <html> <head> <script type="text/javascript"> function whichButton(event) { if (event.button==2) { alert("You clicked the right mouse button!"); } else { alert("You clicked the left mouse button!"); } } </script> </head> <body onmousedown="whichButton(event)"> <p>Click in the document. An alert box will alert which mouse button you clicked.</p> </body> </html> ========================= Saalram Publicize yourself ... http://saalram.com ( Free ! ) =========================
"navigator.appName" and "navigator.appVersion" are used to get browser name and version respectively. File : BrowserInfo_JS.html <html> <body> <script type="text/javascript"> var browser=navigator.appName; var b_version=navigator.appVersion; var version=parseFloat(b_version); document.write("Browser name: "+ browser); document.write("<br />"); document.write("Browser version: "+ version); </script> </body> </html> ==================== Publicize yourself ... Free! http://saalram.com ====================
This example code explains us clearly how to catch an error in javascript. Onclick of button we just calling a javascript function "message()". What this "message()" is trying to do here is nothing. It has to pop an alert with "Welcome guest!". But see the code clearly, we have syntax error in javascript try block. instead of "alert" we wrote "adddlert". Actually "adddlert" is not a keyword in javascript. So this html page will get an error at runtime. Here we catching the error description using " err.description ". Simple. Just try once!!! File : tryCatch_JS.html <code> <html> <head> <script type="text/javascript"> var txt=""; function message() { try { adddlert("Welcome guest!"); } catch(err) { txt="There was an error on this page.\n\n"; txt+="Error description: " + err.description + "\n\n"; txt+="Click OK to continue.\n\n"; alert(txt); } } </script> </head> <body> <input type="button" value="View message" onclick="message()" /> </body></html> </code> -- Publicize Yourself... Free! http://saalram.com
Again a simple example given below to baptize about usage of an array in javascript. I have declared an array called "mygirls" <html> <body> <script type="text/javascript"> var x; var mysites = new Array(); mysites[0] = " http://saalram.com"; mysites[1] = " http://saalram.blogspot.com"; mysites[2] = " http://saalram.wordpress.com"; document.write("<b>This is an Array : </b>"); for (x=0;x<mysites.length;x++) { document.write("<center>"+mysites[x] + "<center />"); } </script> </body> </html> -- Publicize Yourself... Free! http://saalram.com
Just simple! Here i am just looping the number "i" from 0 to 5. forloop_JS,html <html> <body> <script type="text/javascript"> for (i = 0; i <= 5; i++) { document.write("The number is " + i); document.write("<br />"); } </script> <h1> loop is i=0;i<=5;i++ </h1> </body> </html> -- Regards, Venki
Hi All, Did you get chance to visit "saalram" site? -- Enjoy! The Saalram Team http://saalram.com
It is very simple. Just define a function in header part of the HTML. Then decide from where you are going to call the function. In this example i have used button "onclick" event to trigger my javascript function and also passing an argument. Check the below example.
argument_JS.html
In JavaScript we can get more inputs from user by prompt box. Just like getting input
from form.
Look at the below example. Here i am just getting the user's name by prompting a box and wishing.
prompt_JS.html
In some scenario we get confirmation box asking "Do you want to save your changes? " with options "Yes" and "No". User can click as per their wish. Wherever the page expects confirmaton from user there we can use confirmation box. It is so simple to do confirmation box with JavaScript. Just see the below example,
confirmation_JS.html
This example demonstrates the If statement.
If the time on your browser is less than 10,you will get a "Good morning" greeting, else greeting will be "Good Afternoon". Script so simple as how we used in other languages like java.
If_JS.html
Given example code explains you clearly how to use variables in JS. Here i have declared two variables called "firstname" and "secondname" and joining these two variable like this "
Write us if you have any queries! Good Luck!!!
Example explains you "How to call an alert box when page on load event ?".
onload_alert.html
Write us (saalram.service@gmail.com) if you have any queries. All the best!
It is very simple to set Header,Paragraphs,Font styles,CSS Styles using JavaScript. Have look at this simple and clear example to do HTML styles using JS.
sample.html
Introduction to Javascript (JS)
- JavaScript is a scripting language
- A scripting language is a lightweight programming language
- A JavaScript is usually embedded directly into HTML pages
- JavaScript is an interpreted language (means that scripts execute without preliminary compilation)
- JavaScript was designed to add interactivity to HTML pages
- JavaScript is used in millions of Web pages to improve the design, validate forms, detect browsers, create cookies, and much more .
Before you continue you should have a basic understanding of the following : HTML / XHTML
Are Java and JavaScript the Same?
NO! Java and JavaScript are two completely different languages in both concept and design!
Java (developed by Sun Microsystems) is a powerful and much more complex programming language - in the same category as C and C++.
What can a JavaScript Do?
- JavaScript can put dynamic text into an HTML page - A JavaScript statement like this: document.write(fname + " " + lname) can write a variable text into an HTML page
- JavaScript can react to events - A JavaScript can be set to execute when something happens, like when a page has finished loading or when a user clicks on an HTML element
- JavaScript can read and write HTML elements - A JavaScript can read and change the content of an HTML element
- JavaScript can be used to validate data - A JavaScript can be used to validate form data before it is submitted to a server. This saves the server from extra processing
- JavaScript can be used to detect the visitor's browser - A JavaScript can be used to detect the visitor's browser, and - depending on the browser - load another page specifically designed for that browser
- JavaScript can be used to create cookies - A JavaScript can be used to store and retrieve information on the visitor's computer.
Javascript History
Language : JavaScript
Official Name : ECMAScript
Designed By : Brendan Eich
Developer : Netscape(ECMA Organisation)
Invented : 1996
Standard was Approved : 1998
First and simple Javascript Example
Create a HelloSaalram.html file and write the given script to write text using JavaScript.
Output: " Hello Saalram! "
Questions ??? Please write us "saalram.service@gmail.com".
Creating RSS feeds with JSP is very very simple. Before you continue you should have a basic understanding of XML,HTML,JSP.
What is RSS?
•RSS stands for Really Simple Syndication
•RSS allows you to syndicate your site content
•RSS defines an easy way to share and view headlines and content
•RSS files can be automatically updated
•RSS allows personalized views for different sites
•RSS is written in XML
More ...
Why use RSS?
RSS was designed to show selected data.
Without RSS, users will have to check your site daily for new updates. This may be too time-consuming for many users. With an RSS feed (RSS is often called a News feed or RSS feed) they can check your site faster using an RSS aggregator (a site or program that gathers and sorts out RSS feeds).
RSS data is small and fast-loading pages
How it works?
•RSS is used to share content between websites.
•With RSS, you register your content with companies called aggregators.
•So, to be a part of it: First, create an RSS document and save it with an .xml extension. Then, upload the file to your website. Next, register with an RSS aggregator. Each day the aggregator searches the registered websites for RSS documents, verifies the link, and displays information about the feed so clients can link to documents that interests them.
RSS and JSP
•JSP is one of best and easiest way to create dynamic RSS feeds.
•<%@page contentType="text/xml" %>
Sample JSP Code ( sample.jsp )
Now run this jsp page and see your RSS feeds. Good Luck!
Write us ( saalram.service@gmail.com ) if you need more clarification on JSP and RSS Feeds.
Free Sign Up
Saalram can be used by,
- Business : Advertise here and get comments.
- Experts : Publicize your skills and let the world wonder you.
- Youngsters : Do learn, love, romance, chat, share and amaze others.
Find jobs and friends.
- Professionals: Present yourself in short and impress the people.
- Innovators : Let the people know about your innovations in a quick way.
- Others : Publicize yourself, Make an announcement, Find friends,
Compose your profile, Meet experts, Learn, Teach, Collaborate with others, and always know " What is new? and Who is doing what?" .
Saalram may help you to,
- Publicize yourself to the world with free of cost.
- Quantify your publicity with Saalram.
- Compose your own profile link and use anywhere.
- Collaborate with others.
- Bring your business high.
- Make out the world trend.
- Probe the people.
- Analyse yourself.
Free Sign Up
Saalram is
- An innovative way to publicize yourself to the world.
- An excellent medium to let the world know about you.
- An elegant mode to announce your words to the word.
In short
"Publicize yourself..." "Let the world know you" "Your words to the world"
|
Saalram Publicize yourself ... http://saalram.com |
Free !!! |
Place your Ad here - Free!!! just drop us a mail ... saalram.service@gmail.com |
Free !!! |
|