Visit Map

Sunday, January 21, 2007

Java Bean Generator from Database table

Hi again,
I have written a small utility to generate the java bean classes from exiting tables whihc are present in the database.
You can gerenarate your bean class/Model classes with a click of button.
Hope this helps you

Create a from in VB and keep one text boxes and list box places two command buttons
Here is code

Dim conn As ADODB.Connection
Private Sub CommandButton1_Click()Set conn = New ADODB.Connectionconn.Open "xxxx", "xxxx", "xxxx"Dim arr As ADODB.Recordsetconn.CursorLocation = adUseClientSet arr = New ADODB.Recordsetarr.Open "select TNAME from tab", conn, adOpenDynamic, adLockOptimisticDo While Not arr.EOF ListBox1.AddItem (arr.Fields(0)) arr.MoveNextLooparr.Close
End Sub
Private Sub CommandButton2_Click()Dim arr As ADODB.RecordsetDim strValue As StringDim strClassName As StringIf (conn Is Nothing) Then MsgBox "get the tables first", vbCritical Exit SubEnd IfSet arr = New ADODB.RecordsetstrClassName = Replace(ListBox1.Text, "_", "")strValue = "public class " & StrConv(strClassName, vbProperCase) & "{" & vbCrLf
arr.Open "select * " & "from " & ListBox1.Text, conn, adOpenDynamic, adLockOptimisticFor i = 0 To arr.Fields.Count - 1 Select Case arr.Fields(i).Type Case adNumeric, adInteger, adSingle, 139 strValue = strValue + "private int " & Replace(StrConv(arr.Fields(i).Name, vbLowerCase), "_", "") & ";" + Chr(13) Case adVarChar strValue = strValue + "private String " & StrConv(Replace(arr.Fields(i).Name, "_", ""), vbLowerCase) + ";" + Chr(13) End SelectNextstrValue = strValue & "}"TextBox1.Text = strValuearr.Close
End Sub
Private Sub UserForm_Click()
End Sub
Private Sub UserForm_Terminate()If Not (conn Is Nothing) Thenconn.CloseEnd IfEnd Sub
Raj

3 comments:

Anonymous said...

viagra patent cheap viagra canada viagra over the counter herbal viagra reviews buy viagra australia viagra for sale without a prescription viagra logo can women take viagra viagra oral free viagra in the uk viagra jelly buy viagra online at viagra rrp australia cost where to buy viagra

Anonymous said...

[url=http://firgonbares.net/][img]http://firgonbares.net/img-add/euro2.jpg[/img][/url]
[b]office 2007 enterprise advantage crack, [url=http://firgonbares.net/]can i buy microsoft software[/url]
[url=http://firgonbares.net/][/url] softwares to buy where to buy cheap software
academic software downloads [url=http://firgonbares.net/]computer software to buy[/url] winzip 12 registration key
[url=http://firgonbares.net/]teacher educational software[/url] windows xp
[url=http://firgonbares.net/]adobe macromedia flash software[/url] windows vista theme for xp
kaspersky removal tool [url=http://firgonbares.net/]buy discontinued software[/b]

Anonymous said...

I want to thank you for this post. This information was very helpful.Please keep up the good work and I look forward to more of your great posts! cheapest tadalafil