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");
}
}

}

Tuesday, February 26, 2013

Deployment Using NAnt

Useful link : http://www.geoffhudik.com/tech/2012/5/5/build-automation-part-1-overview-and-pre-build-tasks.html

Remote Connection


There are several tools available for remote connection and i found it most effective and efficient tools

1. TeamViewer
 
You can connect you machine from Windows to Mac/Mac to Windows or iPad/iPhone/Android to Mac/windows.... Everything is possible. I found it more useful.
You can follow the instruction here
http://www.pcworld.com/article/248991/how_to_log_in_to_your_pc_remotely_with_teamviewer.html


2. Join.me (Meeting &amp; remote control others machine)
https://join.me/

3. LogMeIn
https://secure.logmein.com/products/free/

Monday, February 4, 2013

Create table with string identity column




First, You can not directly create a string IDENTITY column in table definition, But we can achive this following ways

1. We can create a compute column using the IDENTITY column. Compute column means evaluate the value using expression.


Create Table TableName1
(
ID int IDENTITY(1,1),
ComputeStrID As 'AnyStrValue' + CAST( ID as Varchar),
AnyOtherColumn varchar(12)
);


insert into TableName1(AnyOtherColumn) values ('Test')
insert into TableName1(AnyOtherColumn) values ('Test2')
insert into TableName1(AnyOtherColumn) values ('Test3')
insert into TableName1(AnyOtherColumn) values ('Test4')


select * from TableName1

Constrain : Only one identity column per table is allowed.



2. In Code, we can manipulate the db identity value while showing the result in screen, somethink like

String.Format("0{1:000}","AnyStrValue", db.ID)
code is in C#



Home


Just want to share my finding/solutions for the bugs/problems in my technical experience. i'm going to share my knowledge to learn more.

Coming Soon : I'll update the Android Section with very simple example for android app, with step by step instruction.

Post your problem, lets find the solution together. And Keep going.