You are not logged in.

Dear visitor, welcome to Jabaco - Community. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

  • "Riaan Pretorius" is male
  • "Riaan Pretorius" started this thread

Posts: 21

Date of registration: Nov 14th 2009

Location: Krugersdorp, South Africa

Occupation: Linux Opensource Consultant

Hobbies: Programming

  • Send private message

1

Monday, January 11th 2010, 7:55pm

Jabaco/java MySQL Data Manipulation

I found this code on the forums... WORKS GREAT! for searches.. Looking for EDIT and DELETE examples?
Unless you can only do that using SQL commands?



Dim Con As java#sql#Connection
Dim Order As java#sql#Statement
Dim Data As ResultSet


'Load the JDBC-ODBC driver
Class.forName "com.mysql.jdbc.Driver"

'Create connection to the database test
Set Con = java#sql#DriverManager.getConnection("jdbc:mysql://localhost:3306/mydatabase", "mydbuser", "")

'Create a statement and send the command to the database
Set Order = Con.createStatement
Set Data = Order.executeQuery("SELECT * FROM users;")


'Print the result from the select statement
Do While Data.next()
java#lang#system.out.println(Data.getString("username"))
' MsgBox Data.getString("username")+Data.getString("usersurname")
Loop

'Was hoping someone would now how to edit data this way?
'===================================================
Set Order = Con.createStatement(ResultSet.TYPE_FORWARD_ONLY,ResultSet.CONCUR_UPDATABLE)
Set Data = Order.executeQuery("SELECT * FROM users Where username = 'eben';")
Data.next
Data.updateString("username","babes")
Data.updateRow
'===================================================

'Close the connection
Con.close
I am ROOT if you see me laughing you better have a backup! :cursing:

A1880

Intermediate

  • "A1880" is male

Posts: 500

Date of registration: Jan 1st 2009

Location: Hanover, Germany

Occupation: Software Engineer

Hobbies: Hilbert Curves

  • Send private message

2

Monday, January 11th 2010, 11:13pm

You can and should perform all these operations via SQL statements.

Look here.
This is Google's first hit on "JDBC Insert Update Delete".

Any JDBC tutorial will show you the details.

Happy experimenting!

A1880

  • "WhatIsSoftware" is male

Posts: 21

Date of registration: Apr 28th 2012

Location: CyberVillage

Hobbies: Web Development. Android Development. Jabaco Development. :)

  • Send private message

3

Monday, June 11th 2012, 8:20pm

Thanks Riaan and A1, I'ven been looking for documentation on how to connect to SQL via jabaco.

pandapipino

Beginner

Posts: 9

Date of registration: Sep 6th 2012

  • Send private message

4

Thursday, September 6th 2012, 1:18pm

i apply the code on the java grid but everytime it loads the data on the list it freezes the application. Do you guys any idea?

Rate this thread
WoltLab Burning Board