MBS Xojo Developer Conference and Training
Join us from 3rd to 6th May 2017 in Berlin, Germany.

MBS Real Studio Plugin Tutorial Videos

JavaDatabase Source

Note: The function DesktopFolder is deprecated in Real Studio. You can replace it with SpecialFolder.desktop.

Class App
Inherits Application
// Constants
Const kFileQuitShortcut = Ctrl+Q
Const kFileQuit = E&xit
Const kEditClear = &Delete

// Event implementations
Sub Open()
dim j as JavaDatabaseMBS
dim r as JavaRecordSetMBS
dim f as FolderItem


j=new JavaDatabaseMBS(f,"com.mysql.jdbc.Driver")

if j.Connect then
MsgBox "connected"

'j.ExecuteSQL "CREATE DATABASE mytest"
'if j.Error then
'MsgBox j.ErrorString
'end if

j.ExecuteSQL "USE mytest"

'j.ExecuteSQL "CREATE TABLE mytable(test_id int, test_val char(15) not null, PRIMARY KEY (test_id))"
'if j.Error then
'MsgBox j.ErrorString
'end if

'j.ExecuteSQL "INSERT INTO mytable(test_id, test_val) VALUES(1,'One')"
'j.ExecuteSQL "INSERT INTO mytable(test_id, test_val) VALUES(2,'Two')"
'j.ExecuteSQL "INSERT INTO mytable(test_id, test_val) VALUES(3,'Three')"
'j.ExecuteSQL "INSERT INTO mytable(test_id, test_val) VALUES(4,'Four')"
'j.ExecuteSQL "INSERT INTO mytable(test_id, test_val) VALUES(5,'Five')"
'if j.Error then
'MsgBox j.ErrorString
'end if

r=j.SelectSQL("SELECT * from mytable",true)
if r<>Nil then
while r.NextRecord
MsgBox str(r.getInt("test_id"))+" "+r.getString("test_val")

end if

if j.Error then
MsgBox j.ErrorString
end if
MsgBox "Failed to connect"+EndOfLine+j.ErrorString+EndOfLine+str(j.Errorcode)

end if
End Sub
End Class

Class Window1
Inherits Window
End Class

All movies

MBS Xojo Plugins