Tag: recipe

Hibernate with DB Visual Architect tool from VisualParadigm

Important things to note:

1. If you want to see “relationship” fields in generated classes -> in ERD (Entity Relationship Diagram) -> right click on the property -> open specifications -> generated: always
2. Note that it will also require property to be set as NULLABLE and have a default value (i use NULL)
1. If working with NetBeans check that error is not actually happening somewhere in the code. Especially if it says something like:
ERROR JDBCExceptionReporter:101 – Unknown column ‘ParentId’ in ‘where clause’
In addition, compiler will not show you the exact position in the code.
I was so frustrated, I actually started doing manual Hibernate code… till I decided to give it a final try!

How to install PHP on Windows

Installing PHP >= 4.3.1 & 4.1 on Windows 2000 IIS Server

Windows PHP Installation (from the WebSite)

1)       Download the full PHP windows binaries from http://www.php.net. Do NOT use the small installer. Extract the ZIP to c:\php\.
2)       Copy the php.ini-recommended to c:\winnt\php.ini.
3)       Copy php.exe, php4ts.dll, & php4ts.lib to c:\winnt\system32.
4)       Copy the entire contents of c:\php\dlls to c:\winnt\system32.
5)       In IIS, add PHP as an application mapping .php to “c:\php\php.exe %s %s” (minus the quotes, and note the double %s).
6)       Be sure your IIS user (I_USR_xxxxx) has read and execute privileges on c:\php\ and all subfolders.
7)       Edit your c:\winnt\php.ini and be sure the following line is in it.

cgi.force_redirect = 0

MY OWN METHOD:

1. Download binary… the bigger file
2. copy paste php.ini to C:/windows
– must change : extension_dir = “C:\php\extensions\”
– might change: include_path = “.;c:\php\includes”
– might change: extension=php_curl.dll (remove ; in front of line)
3. copy php4ts.lib, php4ts.dll, php.exe to windows\system32
4. copy all files withing dlls into windows\system32
5. make sure php directory has access to “I_USR xxx” enabled
6. in IIS, computer name->properties->Internet Information Services-> WWWService-> Edit
– home page-> settings->add .php (c:\php\isapi\php4isapi.dll)
– Isapi FIlters-> add-> PHP (c:\php\isapi\php4isapi.dll)
7. might do : make necessary directory Public Website..

8. test… <? phpinfo();?>

also check this:

How To Install PHP on IIS 6.0

http://www.webpronews.com/expertarticles/2006/06/19/installing-php-on-iis-windows-xp-pro
http://www.php.net/install.windows

Installing PHP >= 4.3.1 & 4.1 on Windows 2000 IIS Server

 

Windows PHP Installation (from the WebSite)

 

1)       Download the full PHP windows binaries from http://www.php.net. Do NOT use the small installer. Extract the ZIP to c:\php\.

2)       Copy the php.ini-recommended to c:\winnt\php.ini.

3)       Copy php.exe, php4ts.dll, & php4ts.lib to c:\winnt\system32.

4)       Copy the entire contents of c:\php\dlls to c:\winnt\system32.

5)       In IIS, add PHP as an application mapping .php to “c:\php\php.exe %s %s” (minus the quotes, and note the double %s).

6)       Be sure your IIS user (I_USR_xxxxx) has read and execute privileges on c:\php\ and all subfolders.

7)       Edit your c:\winnt\php.ini and be sure the following line is in it.

 

cgi.force_redirect = 0

 

MY OWN METHOD:

 

1. Download binary… the bigger file

2. copy paste php.ini to C:/windows

– must change : extension_dir = “C:\php\extensions\”

– might change: include_path = “.;c:\php\includes”

– might change: extension=php_curl.dll (remove ; in front of line)

3. copy php4ts.lib, php4ts.dll, php.exe to windows\system32

4. copy all files withing dlls into windows\system32

5. make sure php directory has access to “I_USR xxx” enabled

6. in IIS, computer name->properties->Internet Information Services-> WWWService-> Edit

– home page-> settings->add .php (c:\php\isapi\php4isapi.dll)

– Isapi FIlters-> add-> PHP (c:\php\isapi\php4isapi.dll)

7. might do : make necessary directory Public Website..

 

8. test… <? phpinfo();?>

 

also check this:

http://www.iisadmin.co.uk/?p=4

http://www.webpronews.com/expertarticles/2006/06/19/installing-php-on-iis-windows-xp-pro

http://www.php.net/install.windows

 

The best data structures to manipulate data manually = DataTable + DataRow + DataView

Here is a simple class that populates GridView control.
This is the best method for doing MANUAL data manipulations.
Code is in C# and VB.NET formats

C#
<%@ Import Namespace="System.Data" %>
<html>
<script language="C#" runat="server">

 string SortField;

 ICollection CreateDataSource() {
 DataTable dt = new DataTable();
 DataRow dr;

 dt.Columns.Add(new DataColumn("IntegerValue", typeof(Int32)));
 dt.Columns.Add(new DataColumn("StringValue", typeof(string)));
 dt.Columns.Add(new DataColumn("DateTimeValue", typeof(DateTime)));
 dt.Columns.Add(new DataColumn("BoolValue", typeof(bool)));
 dt.Columns.Add(new DataColumn("CurrencyValue", typeof(double)));

 for (int i = 0; i < 9; i++) {
 dr = dt.NewRow();

 dr[0] = 9-i;
 dr[1] = "Item " + i.ToString();
 dr[2] = DateTime.Now;
 dr[3] = (i % 2 != 0) ? true : false;
 dr[4] = 1.23 * (i+1);

 dt.Rows.Add(dr);
 }

 DataView dv = new DataView(dt);
 dv.Sort = SortField;
 return dv;
 }

 void Page_Load(Object sender, EventArgs e) {
 if (!IsPostBack) {
 if (SortField == "") {
 SortField = "IntegerValue";
 }    
 BindGrid();
 }    
 }

 void MyDataGrid_Sort(Object sender, DataGridSortCommandEventArgs e) {
 SortField = (string)e.SortExpression;
 BindGrid();
 }

 void BindGrid() {
 MyDataGrid.DataSource = CreateDataSource();
 MyDataGrid.DataBind();
 }

</script>

<body>

 <h3><font face="Verdana">Basic Sorting in DataGrid</font></h3>

 <form runat=server>

 <ASP:DataGrid id="MyDataGrid" runat="server"
 AllowSorting="true"
 OnSortCommand="MyDataGrid_Sort"
 BorderColor="black"
 BorderWidth="1"
 CellPadding="3"
 Font-Name="Verdana"
 Font-Size="8pt"
 HeaderStyle-BackColor="#ccccff"
 HeaderStyle-ForeColor="black"
 />

</form>

</body>
</html>

VB.NET
<%@ Import Namespace="System.Data" %>

<html>
<script language="VB" runat="server">

 Dim SortField As String

 Function CreateDataSource() As ICollection

 Dim dt As DataTable
 Dim dr As DataRow
 Dim i As Integer

 'create a DataTable
 dt = New DataTable
 dt.Columns.Add(New DataColumn("IntegerValue", GetType(Integer)))
 dt.Columns.Add(New DataColumn("StringValue", GetType(String)))
 dt.Columns.Add(New DataColumn("DateTimeValue", GetType(DateTime)))
 dt.Columns.Add(New DataColumn("BoolValue", GetType(Boolean)))
 dt.Columns.Add(new DataColumn("CurrencyValue", GetType(Double)))

 'Make some rows and put some sample data in
 For i = 1 To 9
 dr = dt.NewRow()
 dr(0) = 9-i
 dr(1) = "Item " & i.ToString()
 dr(2) = DateTime.Now.ToShortTimeString
 If (i Mod 2 <> 0) Then
 dr(3) = True
 Else
 dr(3) = False
 End If
 dr(4) = 1.23 * (i + 1)
 'add the row to the datatable
 dt.Rows.Add(dr)
 Next

 'return a DataView to the DataTable
 Dim dv as DataView = New DataView(dt)
 dv.Sort = SortField
 CreateDataSource = dv
 End Function        

 Sub Page_Load(sender As Object, e As EventArgs)
 If Not IsPostBack Then
 If SortField = "" Then
 SortField = "IntegerValue"
 End If   
 BindGrid
 End If
 End Sub

 Sub MyDataGrid_Sort(sender As Object, e As DataGridSortCommandEventArgs)
 SortField = e.SortExpression
 BindGrid
 End Sub

 Sub BindGrid()
 MyDataGrid.DataSource = CreateDataSource()
 MyDataGrid.DataBind
 End Sub

</script>

<body>

 <h3><font face="Verdana">Basic Sorting in DataGrid</font></h3>

 <form runat=server>

 <ASP:DataGrid id="MyDataGrid" runat="server"
 AllowSorting="true"
 OnSortCommand="MyDataGrid_Sort"
 BorderColor="black"
 BorderWidth="1"
 CellPadding="3"
 Font-Name="Verdana"
 Font-Size="8pt"
 HeaderStyle-BackColor="#ccccff"
 HeaderStyle-ForeColor="black"
 />

</form>

</body>
</html>