Programming
How to create a html parser in java
I created this simple HTML parser to strip out page title, meta description and keywords from web pages.
I made this as a part of my search engine "pipilika" project. You can use this to meet a very basic parsing of HTML. It is still under development. So the commented areas may be bugful. So be sure before to uncomment and use them.
Create a window using window.h in c
This sample code will create a basic window using window.h in c language
#include <windows.h>
const char g_szClassName[] = "myWindowClass";
// Step 4: the Window Procedure
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch(msg)
{
case WM_CLOSE:
DestroyWindow(hwnd);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hwnd, msg, wParam, lParam);
}
return 0;
}
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow)
{
WNDCLASSEX wc;
HWND hwnd;
MSG Msg;
//Step 1: Registering the Window Class
wc.cbSize = sizeof(WNDCLASSEX);
wc.style = 0;
wc.lpfnWndProc = WndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
wc.lpszMenuName = NULL;
wc.lpszClassName = g_szClassName;
wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
if(!RegisterClassEx(&wc))
{
MessageBox(NULL, "Window Registration Failed!", "Error!",
MB_ICONEXCLAMATION | MB_OK);
return 0;
}
// Step 2: Creating the Window
hwnd = CreateWindowEx(
WS_EX_CLIENTEDGE,
g_szClassName,
"The title of my window",
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT, 640, 480,
NULL, NULL, hInstance, NULL);
if(hwnd == NULL)
{
MessageBox(NULL, "Window Creation Failed!", "Error!",
MB_ICONEXCLAMATION | MB_OK);
return 0;
}
ShowWindow(hwnd, nCmdShow);
UpdateWindow(hwnd);
// Step 3: The Message Loop
while(GetMessage(&Msg, NULL, 0, 0) > 0)
{
TranslateMessage(&Msg);
DispatchMessage(&Msg);
}
return Msg.wParam;
}
No CommentsHow to connect to oracle database using java
I have oracle 10g installed on my ubuntu. I need a java program to connect with oracle database and fetch data from table.
To do this what I needed first is the oracle-jdbc connector. I found it in “/usr/lib/oracle/xe/app/oracle/product/10.2.0/server/jdbc/lib” directory. Two jar files named “ojdbc14.jar” & “ojdbc14_g.jar”.
I openned Netbeans IDE created a new project and from the projects panel i right clicked on the project I connect with oracle and clicked on properties.
When properties window openned I went to Libraries to add those specific jar files.
Then I clicked “Add JAR/Folder” and selected those two files and hit ok.
That added those connector jar files in classpath for my current project. Now all what i needed to do is to write the correct code.
No CommentsEclidean GCD by Substraction
Euclidean GCD is a method or algorithm for calculating GCD (Greatest Common Divisor). I implemented this in C. To know details about euclidean gcd visit details of this methon in wikipedia
http://en.wikipedia.org/wiki/Euclidean_algorithm
No CommentsHow to connect C# with oracle
This time I am gonna work with my database project. This course was on oracle database. So now I must connect my software interface with oracle. So first try’t with C#. This is how I did it
To connect to oracle database using C# first you what you must do is to install Oracle Database and Microsoft Visual Studio in your computer.
You also should setup oracle cilent in order to have them work with each other.
Connect to Microsoft Access .mdb database using C#
Here is a simple example that will tell you how to connect to microsoft access (mdb) files in C# .NET. To do this you have to make use OLEDB connector
The first you need is to use OLEDB connector.
First we need to use oledb connector namespace.
using System.Data.OleDb;
Now we need to create an instance of OleDbConnection object. The following will be the connection string required to use as parameter of OleDbConnection instance object
2 CommentsConnect to mysql database using C#
I searched Internet a lot before I could figure out how to connect to mysql database server using C#. This is the one that worked in my favour.
To connect to mysql database using C# first you should have to download a small program called mysql connector .net from MySQL’s official site. Click here to visit this link to download mysql connector .net
6 Comments