Friday, December 13, 2013

Check whether xp_cmdshell is disabled or not

Xp_Cmdshell

- Spawns a Windows command shell and passes in a string for execution.

The Windows process spawned by xp_cmdshell has the same security rights as the SQL Server service account.
xp_cmdshell operates synchronously. Control is not returned to the caller until the command-shell command is completed.
xp_cmdshell can be enabled and disabled by using the Policy-Based Management or by executing sp_configure
To check whether xp_cmdshell is disabled or not. Run the following Query.
SELECT CONVERT(INT, ISNULL(value, value_in_use)) AS config_value
FROM sys.configurations
WHERE name = 'xp_cmdshell' ;


To enable the xp_cmdshell, you can refer the following msdn doc.

Reference : http://technet.microsoft.com/en-us/library/ms175046(v=sql.105).aspx
                 http://technet.microsoft.com/en-us/library/ms190693(v=sql.105).aspx
                 

Thursday, December 12, 2013

JQuery InnerFade Issue

I have recently used the Jquery plugin "Innerfade",  to fade in and out any element included in the container.

Reference : http://medienfreunde.com/lab/innerfade/

Its very easy and so simple. But, one issue that really bugged me is that, if i left my browser open for awhile, then all the images with in the container will start fading fast on top of the another image

I found the bug fix for this. If you experiencing the same issue using innerfade plugin. You can modify the "jquery.innderfade.js" script line 93 and 96 as i did. It fixed the issue.


line 93...$(elements[last]).stop(true,true).slideUp(settings.speed);
line 96...$(elements[last]).stop(true,true).fadeOut(settings.speed);
Reference link : http://computeraxe.com/jquery-stop-action-improves-innerfade-plugin/

Wednesday, December 11, 2013

PHP and C#.Net MD5 code mismatch

Are you experiencing the MD5 code mismatch, even though you are using the same string and key in Php and dot net? Of course it does... Since we need to convert the string + key into ASCII bites. You can use the below code in C#.Net to match the MD5 code in php.


               var strKey = "********";
               var strValue = "abcd";

                byte[] asciiBytes = ASCIIEncoding.ASCII.GetBytes(strValue  + strKey);
                byte[] hashedBytes = MD5CryptoServiceProvider.Create().ComputeHash(asciiBytes);
                string hashedString = BitConverter.ToString(hashedBytes).Replace("-", "").ToLower();

Tuesday, November 26, 2013

Sass Vs SCSS

Css is taking its form to next level, by including scripts in it and I'm seeing lot of question, discussion about the SASS and SCSS... which one to follow, which is easy....what is the difference...

Here, I'm going to summarize what i found and examples are taken from wikipedia...;-)

SASS


Sass (Syntactically Awesome Stylesheets) is the scripting laugage that is interpreted into CSS. And It has 2 syntaxes.

1.  Indented syntax - uses indentation to separate code blocks
2. SCSS (Sassy CSS) - uses block formatting like that of CSS

SassScript provides the following mechanisms: variables, nesting, mixins, and selector inheritance

Variables : 

$margin: 20px;

body
 margin : $margin / 2

Nesting:

table.hl {
  margin: 2em 0;
  td.ln {
    text-align: right;
  }
}

Equilent CSS : 

table.hl {
  margin: 2em 0;
}
table.hl td.ln {
  text-align: right;
}

Mixins:

Most helpful feature, to avoid repeated code and easy modification in CSS.

@mixin table-base {
  th {
    text-align: center;
    font-weight: bold;
  }
  td, th {padding: 2px}
}

#data {
  @include table-base;
}

Equivalent Css:

#data th {
  text-align: center;
  font-weight: bold;
}
#data td, #data th {
  padding: 2px;
}

Selector Inheritance:

Interestingly, you can implement inheritance as like java / c# by using extend keyword.

.error {
  border: 1px #f00;
  background: #fdd;
}
.error.intrusion {
  font-size: 1.3em;
  font-weight: bold;
}

.badError {
  @extend .error;
  border-width: 3px;
}

Equivalent to

.error, .badError {
  border: 1px #f00;
  background: #fdd;
}

.error.intrusion,
.badError.intrusion {
  font-size: 1.3em;
  font-weight: bold;
}

.badError {
  border-width: 3px;
}

You can get more information from : http://sass-lang.com/guide

SCSS


The new main syntax (as of Sass 3) is known as “SCSS” (for “Sassy CSS”)

So, most people with interchange the term SASS and SCSS...Dont get confused....
When you become the master of SASS, check out the "Foundation" framework....
http://foundation.zurb.com/docs/index.html

Its simply awesome (http://foundation.zurb.com/business/why-foundation.html ).... You can design the website so quick and fast with Responsive Web design. 

Thursday, November 14, 2013

Git Commands - Quick Reference

Install git in Mac
http://code.google.com/p/git-osx-installer, Other OS, please refer here : http://git-scm.com/book/en/Getting-Started-Installing-Git


Initialize a Git repository and make the first commit

$ git init
$ git add .
$ git commit -m "Initial commit"

Create a new repository and push it up to GitHub:

$ git remote add origin git@github.com:<username>/demo_app.git
$ git push origin master

Create a branch and switch to the branch at the same time

$ git checkout  - b newbranch-dev
(or)

$ git branch  newbranch-dev
$ git checkout newbranch-dev

To List out the available Branch

$ git branch -a

To switch to master branch

$ git checkout master
$ git branch -a

To push the changes to particular branch. (origin is the remote created for the git url using <<git remote add command>>)

$ git push origin newbranch-dev

To get the latest version by cloning the git project, for first time (Reference : http://git-scm.com/book/en/Git-Basics-Getting-a-Git-Repository)

$ git clone <<git clone public URL>>

To get the latest version from the git project after cloning. (origin is the remote created for the git url using <<git remote add command>>)

$ git pull origin newbranch-dev

To find the difference between current working copy and last version

$ git diff HEAD


To find the difference between any commit and Last version, you can get the commit_id by using this command(
$ git log -4 --pretty="%h - %s" - will give last 4 commits)

$ git diff commit_id HEAD


To find the difference between last version and previous commit


$ git diff HEAD^ HEAD

To get the current configured git user information

$ git config --list

To undo local changes and restore them to the current versions in the repository

$ git reset --hard

Thursday, November 7, 2013

Parameter Count Mismatch

O boy!.... Today, I bang my head to solve this issue....

I was trying to Send an attachment email through Dot Net Amazon SDK. But, got stuck with this issue.. Since the following code is standard, that you can get from internet, to convert the MailMessage To MemoryStream. Finally identify the issue and solved.

public static MemoryStream ConvertMailMessageToMemoryStream(MailMessage message)
        {
            Assembly assembly = typeof(SmtpClient).Assembly;
            Type mailWriterType = assembly.GetType("System.Net.Mail.MailWriter");
            MemoryStream fileStream = new MemoryStream();
            ConstructorInfo mailWriterContructor = mailWriterType.GetConstructor(BindingFlags.Instance | BindingFlags.NonPublic, null, new[] { typeof(Stream) }, null);
            object mailWriter = mailWriterContructor.Invoke(new object[] { fileStream });
            MethodInfo sendMethod = typeof(MailMessage).GetMethod("Send", BindingFlags.Instance | BindingFlags.NonPublic);
            sendMethod.Invoke(message, BindingFlags.Instance | BindingFlags.NonPublic, null, new[] { mailWriter, true}, null); // Throws Error , Parameter Count Mismatch
            MethodInfo closeMethod = mailWriter.GetType().GetMethod("Close", BindingFlags.Instance | BindingFlags.NonPublic);
            closeMethod.Invoke(mailWriter, BindingFlags.Instance | BindingFlags.NonPublic, null, new object[] { }, null);
            return fileStream;
        }


You have to change the parameter array object. Since "Send" Private method has three parameters System.Net.Mail.MailMessage.Send(BaseWriter writer, bool sendEnvelope, bool allowUnicode).

Correct Code


public static MemoryStream ConvertMailMessageToMemoryStream(MailMessage message)
        {
            Assembly assembly = typeof(SmtpClient).Assembly;
            Type mailWriterType = assembly.GetType("System.Net.Mail.MailWriter");
            MemoryStream fileStream = new MemoryStream();
            ConstructorInfo mailWriterContructor = mailWriterType.GetConstructor(BindingFlags.Instance | BindingFlags.NonPublic, null, new[] { typeof(Stream) }, null);
            object mailWriter = mailWriterContructor.Invoke(new object[] { fileStream });
            MethodInfo sendMethod = typeof(MailMessage).GetMethod("Send", BindingFlags.Instance | BindingFlags.NonPublic);
            sendMethod.Invoke(message, BindingFlags.Instance | BindingFlags.NonPublic, null, new[] { mailWriter, true, true}, null); // Success
            MethodInfo closeMethod = mailWriter.GetType().GetMethod("Close", BindingFlags.Instance | BindingFlags.NonPublic);
            closeMethod.Invoke(mailWriter, BindingFlags.Instance | BindingFlags.NonPublic, null, new object[] { }, null);
            return fileStream;
        }

Tuesday, November 5, 2013

Processing the Error Log

It hard to search the specific error occurred in the log file, to go through manually, when the file is of huge size.

- to find number times it occurred
-to find the pattern of the error
-or quick review of the error message

I found an easy way to do that, You can use this command not only for log file, any text file. This commands is for Windows machine

>Find "Sent alert email to admin for email" ErrorLog11052013.log >EmailErr.txt

Display all the line that matches ""Sent alert email to admin for email" in the file "ErrorLog11052013.log" and the Output will be redirected to "EmailErr.txt" file.

Thursday, October 10, 2013

Heroku: Permission denied (publickey). fatal: Could not read from remote repository.

You have make sure, you have added the heroku rsa public key to the server from your local machine

Check whether you have a file called "id_rsa.pub" in the .ssh folder. If not you have generate the key. 

Follow the steps:

1. To generate the key : $ ssh-keygen -t rsa
(You will get these prompts, press enter and continue
Enter file in which to save the key (/Users/TestUser/.ssh/id_rsa): 
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: )

2.  Add the key to Heroku server : $ heroku keys:add ~/.ssh/id_rsa.pub

Reference : https://devcenter.heroku.com/articles/keys

Wednesday, September 18, 2013

Enable SQL-Server Agent for non-admin User

Non-admin users will have public access to their databases, and usually SQL Server agent won't show in their Management studio. If you want the public user to create or manage or execute the Jobs in the SQL SERVER, you have to add 3 important SQL Agent fixed database roles to the msdb database.

 SQLAgentUserRole
-  SQLAgentReaderRole
-  SQLAgentOperatorRole


How to add those roles


1. Navigate through Object Explorer -> Security -> Logins(select the user, then right click) -> Properties -> User Mapping -> Login Properties.

2. Select msdb database.

3. Select SQLAgentUserRole, SQLAgentReaderRole and  SQLAgentOperatorRole under Database role membership for : msdb.

That's it. You are good to go....


Monday, September 16, 2013

Wrap up the content in Div and adjust the height and width dynamically

One line CSS3 Property

word-break:break-all;
(or)
word-wrap:break-word;
Works in all browser

.append_data{
   white-space: pre-wrap;      /* CSS3 */   
   white-space: -moz-pre-wrap; /* Firefox */    
   white-space: -pre-wrap;     /* Opera <7 */   
   white-space: -o-pre-wrap;   /* Opera 7 */    
   word-wrap: break-word;      /* IE */
}

Sunday, September 15, 2013

Compare the string, int and nText with a string in TSQL

Compare the string, int and nText data type with a string data type in  CASE WHEN TSQL

In this case, Column1 is a string, 
    
    select case when column1 = 'sometext' then 1 else 0 end
    from table1

In this case, Column1 is an integer, 

    select case when cast(column1 as varchar(max)) = 'sometext' then 1 else 0 end
    from table1

In this case, Column1 is a nText, 

    select case when cast(column1 as nvarchar(max)) = N'sometext' then 1 else 0 end
    from table1


Friday, September 13, 2013

Install PostgreSQL in Mac OX

You can install the PostgreSQL in MacOX in either way using Graphical Interface or through HomeBrew.

Click Here to choose the options : http://www.postgresql.org/download/macosx/

Here, I have used  Graphical installer

Before installing always make sure you are having the maximum shared memory. It is safe to begin the installation, it wont reserve any memory, so there in no harm...

To check the Shared memory : $ sysctl -a

kern.sysv.shmmax=1610612736
kern.sysv.shmall=393216
kern.sysv.shmmin=1
kern.sysv.shmmni=32
kern.sysv.shmseg=8
kern.maxprocperuid=512
kern.maxproc=2048

If you don't have this config, please update your file $sudo vi /etc/sysctl.conf
[You can also get this info in Readme file.]

After editing, restart the machine, to install Postgres.

Double click the "postgresql-9.3.0-1-osx" and just follow the instruction.

To check whether Postgres is installed or not,

Run this cmd on the terminal :
psql -p 5432 -h localhost -U postgres --password

If it comes to the promt "postgres=#", then you are all set... Quit from the postgres console "\q"



Thursday, September 12, 2013

Tuesday, September 10, 2013

Ruby Predefined Variables

This is a list of the frequently used predefined variables in ruby:

Exceptions
$! message of the last exception
$@ backtrace of the last exception

Regexp
$& the string that matched the last last regexp match
$` string preceding $&
$’ string following $&
$+ last parentheses match
$1, $2, $3… parentheses matches
$~ MatchData object containing information about the last match
$= case insensitive flag

Separators
$/ used by gets, readline etc. as a separator (defaults to “\n”)
$\ used by print, write etc. as a separator (defaults to nil)
$, used by Array#join
$; used by String#split

IO
$< program input
$> program output
$stdin standard input
$stdout standard output
$stderr standard error output
$. line number of the last read file
$_ last input line - used by gets, readline

Process
$0 program name
$* command line arguments
$$ PID of the program
$? exit status of the last process
$: $LOAD_PATH
$” all filenames required by the script
$SAFE security level 0-4, 0 having no restrictions and being the default
$DEBUG debugger enabled?

Friday, September 6, 2013

TryRuby

Learn ruby basic commands in 15 minutes using the link http://tryruby.org, Which has command line interpreter, and you can have short desc for each command. You can go back and forth to check.

Thursday, August 29, 2013

Setting the IFrame height dynamically

Awesome HTML5 feature that helps to set the IFrame height dynamically.

Use the following script

<script type="text/javascript" >
$(document).ready(function(){
    window.setInterval(resizeParentIframe, 2000);
 });

var pastHeight = 0;

function resizeParentIframe() {
var currentHeight = document.body.scrollHeight;
if (currentHeight != pastHeight){
pastHeight = currentHeight;
parent.postMessage(document.body.scrollHeight, '*');
}
}
</script>

Wednesday, August 28, 2013

ERROR: Error installing rails: activesupport requires Ruby version >= 1.9.3.

Check whether you are trying to install the correct version of Rails that are compatible with your Ruby Version.

You can check the ruby version by running the cmd "ruby -v"

Rails VersionPossible Ruby VersionsRecommended Ruby Version
1.0–2.11.8.61.8.6
2.21.8.6 or 1.8.71.8.7
2.31.8.6, 1.8.7, or 1.9.11.8.7
3.0–3.21.8.7, 1.9.2, or 1.9.31.9.3
4.0–…1.9.3, 2.0.x2.0.x

then try to install the rails

sudo gem install rails --version 3.2.12

Sunday, August 4, 2013

brew: command not found

If HomeBrew is not installed, Please follow the instruction mentioned here

1. Install XCode, check whether command line tools are installed or not.

2. $ gcc --version

3. It will display "i686-apple-darwin11-llvm-gcc-4.2 (GCC) 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00)
Copyright (C) 2007 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."

4. Then you can execute the following command to install the home brew
$ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

5. It will display "You should run `brew doctor' *before* you install anything." as last sentence after installing the home brew

6. Now type "$ brew doctor" .

7. Before implementing the recommendation, make sure whether it correct or not.

8. Finally, $brew update. That's it.

Reference : http://ricardianambivalence.com/2012/10/02/install-homebrew-on-your-mac-a-tutorial/

Install RVM Error

Can not find compiler and 'make' tool - make sure Xcode and/or Command Line Tools are installed.


1. Check whether you have install Xcode and its command line tools.

2. After installing the XCode, click on Xcode -> Preferences -> downloads

3. Check whether "Command Line Tools" got installed or not.



Thursday, July 18, 2013

System.Web.HttpException: The length of the query string for this request exceeds the configured maxQueryStringLength value

By default, the query string lengths was set to 2048 characters. To change the query strings length, modify the maxQueryStringLength attribute in httpRuntime.
It will be in the web.config file. <system.web> <httpRuntime /> </system.web>
<httpRuntime maxRequestPathLength="260" maxQueryStringLength="2048" />


Tuesday, April 2, 2013

PHP - IFrame - IE issues

I was banging my head for a week to fix the issue with sessions not maintaining in PHP iFrame in IE browser.

I thought this would be helpful for others.

In IIS7, click the site, goto Feature view, click the "HTTP Response Header"


  1. In the Custom HTTP Headers box, click Add.
  2. In the Custom Header Name text box, type p3p.
  3. In the Custom Header Value text box, add your compact codes. For example, to have the following mini header for your site

     P3P: CP="NOI ADM DEV PSAi COM NAV OUR OTR STP IND DEM"


Tuesday, March 12, 2013

MakeCert Error: Too many parameters

Sometime, while copy pasting the command in command prompt the minus sign "-" will be understand differently, so try changing the '-' characters to the correct one. Its will work.


Error: CryptCertStrToNameW failed => 0x80092023 (-2146885597)

You get this error, when the CN contains characters not conform to X500. In your example you use a name such as "CN=norcron-develop". Here the "-" causes the problem. The same also goes for ".", "," and ";" 


Error: WriteFile failed => 0x5 (5)

Open the command prompt as admin

MakeCert.exe not found

You can find this file in Windows SDK

Path : C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin


Use the makecert and pvk2pfx tools that ships with Visual Studio (e.g. C:\Program Files\Microsoft Visual Studio 8\Common7\Tools\Bin\makecert.exe) to create certificate files and private key files.

Makecert.exe –r –pe –n “cn=www.idp.com” –sv idp.pvk idp.cer

You then need to convert the PVK file to a PFX file so it can be loaded with the .NET framework classes.

Pvk2pfx.exe –pvk idp.pvk –spc idp.cer –pfx idp.pfx –po <password>

Refer to the Microsoft help for additional options.

Generate .pem from pfx : http://help.globalscape.com/help/eft6-2/mergedprojects/eft/exporting_a_certificate_from_pfx_to_pem.htm

Wednesday, March 6, 2013

Frequently Used Methods


Browser Close Button detection using JavaScript


    window.onbeforeunload = confirmClose;
            function confirmClose(e){
                var Confirm_Close = "0";
                if(Confirm_Close=="0")
                {
                    var msg = "Are you sure?";
                    if (e) {
                        e.returnValue = msg;
                    }

                    return msg;
                }
                else{
                    Confirm_Close="0";
                }
            }



Detect any hyperlinks detection event


$(".pageclass a").click(function()
{
});


Relief from tool-tip headache

http://jqueryui.com/tooltip/#tracking

Saturday, March 2, 2013

First Android App

Are you ready to start creating your own App?

If you are not familiar with android application development environment, click here.

Let's Start.

In this example, I have just given the multi-line text in the screen. The main intention of this app, is just make yourself feel proud that you have created Your own app and get familiarized with the Eclipse ADT. Later we can see how can we build sophisticated app.

First, Create the Android Application project,

click on the img for original size

You will get the option to give the application name, project name and package name. And also, select the SDK version and theme.

click on the img for original size


Click Next, Configure Project option screen will appear, -> Click Next. Configure Launcher Icon -> Click Next. Create Activity -> Select FullScreenActivity -> Click Next. New FullScreen Activity -> Give the name for your Activity and Layout. Click Finish. You will see the IDE, just like below, if you choose the perspective as "Java Browsing"(Menu->Windows->Open Perspective->Java Browsing).

click on the img for original size




If you execute your project, It will ask you to choose the Android Virtual Device. Click the Manager and configure it as like

click on the img for original size

Click Ok and execute, your first app is ready. 

click on the img for original size


Soon, I'll update this post for the following questions, that I assume already popped up in your mind.... Keep following the post.


What is FrameLayout?

What is Activity class and Does all the class should inherit the Activity class?

What the members of activity class? which is most frequently used members?

What are auto-generated java files? Can we modify the auto-generate java files?

What are the required JAR files?

How can we test the Android app locally and in App Store?

How can we upload our App in PlayStore and reachable to everyone?

What is the best way to define the configuration for AVD(Andriod Virtual device)?




Thursday, February 28, 2013

Android Application Development Ennvironment Set up


There are two ways to set the eclipse for Android development.

a. Directly download the ADT bundle(Eclipse + Android SDk + SDK update Manager), which is very easy and simple way
b. Install Eclipse separately and set up the Android SDK for existing eclipse, which involves little more configuration.

We can see both ways of setting up the Android development environment.

(a) Easy Way, Steps

1. Download the ADT(Android Development Tools) Bundle, which has both eclipse and APK setup. advantage of using this is you no need to setup the Eclipse IDE for android development  Its all set up already. Click <a href= "http://developer.android.com/sdk/index.html">here</a> to download the ADT Bundle.

2. Unzip the downloaded adt-bundle-<os_platform>.zip and save it in your own convenient directory, instead of download.

3. Run the adt-bundle-<os_platform>/eclipse/eclipse.exe, it will launch the eclipse. That's it. Start the development.

(b)ADK Configuration for exiting Eclipse

I'll update this section quickly, with proper screen shots... 

Wednesday, February 27, 2013

ClassNotFoundException for com.microsoft.sqlserver.jdbc.SQLServerDriver


Check whether you have correct Jar file included in your project.

The Microsoft JDBC Driver for SQL Server provides sqljdbc.jar and sqljdbc4.jar class library files to be used depending on your preferred Java Runtime Environment (JRE) settings. For more information about which JAR file to choose, see System Requirements for the JDBC Driver.

The sqljdbc.jar class library provides support for JDBC 3.0 and the sqljdbc4.jar class library provides support for JDBC 4.0.

For more information, please see:

System Requirements for the JDBC Driver
http://msdn.microsoft.com/en-us/library/ms378422.aspx

Using the JDBC Driver
http://msdn.microsoft.com/en-us/library/ms378526.aspx

You can download the sqljdbc4.jar, here : Microsoft JDBC Driver for SQL Server

ClassNotFoundException for com.microsoft.jdbc.sqlserver.SQLServerDriver


If you got this error, probably you are using wrong reference.
com.microsoft.jdbc.sqlserver.SQLServerDriver is used for Microsoft 2000 SQL SERVER.

For 2005 SQL SERVER and grester version, you have use "com.microsoft.sqlserver.jdbc.SQLServerDriver".

Note the change: from "microsoft.jdbc.sqlserver" to "microsoft.sqlserver.jdbc"

And also for SQL SERVER 2005, it has different URL prefix, The SQL Server 2000 JDBC driver uses an URL prefix of "jdbc:microsoft:sqlserver://", while the SQL Server 2005 JDBC driver uses an URL prefix of "jdbc:sqlserver://".
Note the removal of "microsoft" from the URL prefix.

For more information about the connection string properties, you can refer : http://msdn2.microsoft.com/en-us/library/ms378428(SQL.90).aspx

JDBC Connection for SQL SERVER


 Create two class "JDBCConnector" and "TestConnection" in same package. Replace the values YourServerNameorIp, YourDBInstanceName, YourDBUserName and YourDBPassword with Appropriate values.


This sample code works fine with SQL SERVER 2008,

Kindly let me know if it is not working any of the sql server version.


JDBCConnector.Java


import java.sql.Connection;
import java.sql.DriverManager;


public class JDBCConnector {

public JDBCConnector()
{
MakeConnection("YourServerNameorIp", 
"YourDBInstanceName", "YourDBUserName", "YourDBPassword");
}
private void MakeConnection(String strServerIPAddress, 
String strDatabaseName, String strUserName, String strPassword)
{
if(openConnection(strServerIPAddress, 
strDatabaseName, strUserName, strPassword))
{
System.out.println("Test Connection Successful");
}
else
{
System.out.println("Test Connection not succesful");
}
}

private boolean openConnection(String strServerIPAddress, 
String strDatabaseName, String strUserName, String strPassword) {
//String connect to SQL server
String url = "jdbc:sqlserver://" + strServerIPAddress + ":1433" +
";DatabaseName=" + strDatabaseName;

try
{
//Loading the driver... 
Class.forName( "com.microsoft.sqlserver.jdbc.SQLServerDriver" );
}
catch( java.lang.ClassNotFoundException e )
{
System.out.println("ClassNotFoundException");
return false;


try
{
//Building a Connection
Connection m_Conn = DriverManager.getConnection(url, strUserName, strPassword); 
if(m_Conn == null )
return false; 
}
catch( java.sql.SQLException e )
{
System.out.println("Connection error");
return false;

return true; 
}

}

TestConnection.Java


public class TestConnection
{
public static void main(String[] args) {
// TODO Auto-generated method stub
try
{
JDBCConnector conn = new JDBCConnector();
}
catch (Exception ex)
{
System.out.println("base class not found");
}
}

}