How to add jdbc for Microsoft SQL Server to NetBeans

This short post shows you a quick step to add the jdbc for Microsoft SQL Server to NetBeans.

I keep reading in MSDN forum, most of the people are having problem to add the jdbc jar file to the IDE then keep blaming the jdbc not working.

Somehow the blame is not entirely untrue. I am using

– NetBeans 8.0.2

– JDK 1.7

sqljdbc42.jar is not supported but sqljdbc41.jar is working fine.

Let’s go back to the key point here. To add the jdbc jar to NetBeans IDE, you just need to right click the Libraries node and choose Add JARFolder…

netbeans

To add the JAR file to Eclipse IDE, you see refer to https://chanmingman.wordpress.com/2015/04/23/failed-to-load-the-sqljdbc_auth-dll-cause-no-sqljdbc_auth-in-java-library-path/.

Posted in .Net, Community, Java | Tagged , , , | Leave a comment

Read Excel XLSX using ODBC drive and C#

This code snippet is to read the Excel xlsx file using ODBC driver.

First you need to download the xlsx ODBC here https://www.microsoft.com/en-us/download/details.aspx?id=23734. It is written 2007 Office System Driver: Data Connectivity Components but I don’t have issue to use it in Excel 2016.

The code pick up the table name TABLE_NAME and fill it into Dataset. You must define a table if you want to use the code below.

public static  Boolean ImportExcel2007(String strFilePath, ref DataSet ds)

{

    if (!File.Exists(strFilePath)) return false;

    String strExcelConn = “Provider=Microsoft.ACE.OLEDB.12.0;”

    + “Data Source=” + strFilePath + “;”

    + “Extended Properties=’Excel 8.0;HDR=No'”;

    OleDbConnection connExcel = new OleDbConnection(strExcelConn);

    OleDbCommand cmdExcel = new OleDbCommand();

    try

    {

        cmdExcel.Connection = connExcel;

 

        //Check if the Sheet Exists

        connExcel.Open();

        DataTable dtExcelSchema;

        //Get the Schema of the WorkBook

        dtExcelSchema = connExcel.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null);

        connExcel.Close();

 

        //Read Data from Sheet1

        connExcel.Open();

        OleDbDataAdapter da = new OleDbDataAdapter();

        //DataSet ds = new DataSet();

        string SheetName = dtExcelSchema.Rows[0][“TABLE_NAME”].ToString();

        cmdExcel.CommandText = “SELECT * From [“ + SheetName + “]”;

 

        //Range Query

        //cmdExcel.CommandText = “SELECT * From [” + SheetName + “A3:B5]”;

 

        da.SelectCommand = cmdExcel;

        da.Fill(ds);

 

        connExcel.Close();

        return true;

    }

    catch

    {

        return false;

    }

    finally

    {

        cmdExcel.Dispose();

        connExcel.Dispose();

    }

}

Posted in .Net, Community, Microsoft Office | Tagged , , , | Leave a comment

Run Android Emulator using ionic

This short article shows you the journey to reach this Android Emulator.

If you want to run Android Emulator from ionic then you may go through

https://chanmingman.wordpress.com/2016/01/22/please-install-android-target-android-22/

https://chanmingman.wordpress.com/2016/01/24/error-could-not-create-the-java-virtual-machine/

https://chanmingman.wordpress.com/2016/01/24/this-computer-does-not-support-intel-virtualization-technology-vt-x/

The last thing (probably) is to uninstall your VMWare or Disable the Hyper-V feature in your machine. The you can have the Android Emulator Running when issue ionic emulate android.

clip_image002

Posted in .Net, Community, Java | Tagged , , | Leave a comment

How to update Active Directory using C#

This code snippet shows you how to update the attribute in AD using C#.

You must get the LDAP server path correct with the user has administrators permission.

DirectoryEntry entry = new DirectoryEntry(“LDAP://server.localdomain.local”, “kenny”, “password”);

Specify the user that you want to change

mySearcher.Filter = “samaccountname=” + accuntName;

Specify the attribute that you want to change.

mySearcher.PropertiesToLoad.Add(“department”);

Retrieve the user

mySearchResult = mySearcher.FindOne();

Assign the new value to the attribute.

myDirectoryEntry.Properties[“department”].Value = department;

Update the user

myDirectoryEntry.CommitChanges();

The complete code snippet as below:

public static void ADUpdate(string accuntName, string department, string title)

{

    DirectoryEntry entry = new DirectoryEntry(“LDAP://server.localdomain.local”, “kenny”, “password”);

 

    DirectorySearcher mySearcher = new DirectorySearcher(entry);

 

    //obama is the user name that you want to search

 

    //ResultPropertyCollection prop;

    mySearcher.Filter = “samaccountname=” + accuntName;

    SearchResult mySearchResult;

 

    //mySearcher.PropertiesToLoad.Add(“telephonenumber”);

    mySearcher.PropertiesToLoad.Add(“department”);

    mySearcher.PropertiesToLoad.Add(“title”);

    mySearchResult = mySearcher.FindOne();

 

    if (mySearchResult != null)

    {

        //// Get the ‘DirectoryEntry’ that corresponds to ‘mySearchResult’.

        DirectoryEntry myDirectoryEntry = mySearchResult.GetDirectoryEntry();

 

        //myDirectoryEntry.Properties[“telephonenumber”].Value = “2152”;

        myDirectoryEntry.Properties[“department”].Value = department;

        myDirectoryEntry.Properties[“title”].Value = title;

        myDirectoryEntry.CommitChanges();

 

        myDirectoryEntry.Dispose();

    }

}

Posted in .Net, Community, Operating System | Tagged , , | Leave a comment

Task Manager vs Process Explorer

This is a short article that let you know there is alternative to Task Manager.

One day my colleague has told me his laptop has been taking long time to start. So the Process Explorer cross my mind.  

The obvious comparison below between the Properties in Task Manager and the Properties in Process Explorer for the same process (PID 7000).

clip_image002[8]

You may not find some of the below Process Explorer features in Task Manager.

·        The default tree view shows the hierarchical parent relationship between processes, and displays using colors to easily understand processes at a glance.

·        Very accurate CPU usage tracking for processes.

·        Can be used to replace Task Manager, which is especially useful on XP, Vista, and Windows 7.

·        Can add multiple tray icons to monitor CPU, Disk, GPU, Network, and more.

·        Figure out which process has loaded a DLL file.

·        Figure out which process is running an open window.

·        Figure out which process has a file or folder open and locked.

·        View complete data about any process, including threads, memory usage, handles, objects, and pretty much anything else there is to know.

·        Can Kill an entire process tree, including any processes started by the one you choose to kill.

·        Can Suspend a process, freezing all its threads so they do nothing.

·        Can see which thread in a process is actually maxing out the CPU.

·        The latest version (v16) integrates VirusTotal into the interface so you can check a process for viruses without leaving Process Explorer.  

To download Process Explorer go here: https://technet.microsoft.com/en-us/sysinternals/processexplorer.aspx

More information:

http://www.howtogeek.com/school/sysinternals-pro/lesson2/

Posted in Community, Operating System | Tagged , , | Leave a comment

This computer does not support Intel Virtualization Technology VT-x

This short article provides you the possible reasons for getting the error “This computer does not support Intel Virtualization Technology (VT-x)”.

When you run intelhaxm-android.exe from C:\Program Files (x86)\Android\android-sdk\extras\intel\ Hardware_Accelerated_Execution_Manager then you got the error:

This computer does not support Intel Virtualization Technology (VT-x). HAXM cannot be installed.

 

clip_image001

1. Make sure your PC support VT-x.

2. Make sure you enable VT-x in your PC.

3. If you are running Windows and you have AMD-V then it is not supported. http://developer.android.com/tools/devices/emulator.html

Posted in Community, Operating System | Tagged , , , | 1 Comment

CPU acceleration status: HAX kernel module is not installed

This short article is showing you how to resolve “CPU acceleration status: HAX kernel module is not installed”.

When you are trying to setup an Android Emulator and Start it then you hit the error below.

clip_image001

Make sure you have the Intel x86 Emulator Accelerator installed.

clip_image002

 The run intelhaxm-android.exe from C:\Program Files (x86)\Android\android-sdk\extras\intel\ Hardware_Accelerated_Execution_Manager.

Posted in Community, Java | Tagged , , | Leave a comment