This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 132989

Summary: StringIndexOutOfBoundsException: String index out of range: 140
Product: db Reporter: Roman Mostyka <romanmostyka>
Component: SQL EditorAssignee: David Vancouvering <davidvc>
Status: VERIFIED FIXED    
Severity: blocker CC: sustaining
Priority: P2    
Version: 6.x   
Hardware: All   
OS: All   
URL: http://statistics.netbeans.org/exceptions/detail.do?id=47351
Issue Type: DEFECT Exception Reporter: 47351
Attachments: stacktrace

Description Roman Mostyka 2008-04-16 12:48:03 UTC
Build: NetBeans IDE 6.1 RC1 (Build 200804100130)
VM: Java HotSpot(TM) Client VM, 10.0-b19, Java(TM) SE Runtime Environment, 1.6.0_05-b13
OS: Windows XP, 5.1, x86

User Comments: 
1. Add MySQL DB to an IDE (try jdbc:mysql://rave-db.russia.sun.com/travel or jdbc:mysql://jbrave-pc1.sfbay.sun.com/travel; login/password for both is 'travel').
2. Open SQL Editor and add following code:
delimiter ??
create procedure test() as
begin
set x = select count(*) from person;
if x == 2
  select * from trip;
end if;
end??
delimiter ;
3. Run query.

Result: StringIndexOutOfBoundsException arises.
Comment 1 Roman Mostyka 2008-04-16 12:48:07 UTC
Created attachment 60270 [details]
stacktrace
Comment 2 Roman Mostyka 2008-04-16 12:49:40 UTC
I set priority to P2 because I don't see any workaround. If there is some, please let me know and downgrade priority
back to P3.
Comment 3 David Vancouvering 2008-04-16 16:33:38 UTC
I was able to reproduce.  It's an off-by-one error in my parsing.

The workaround is to add an extra space after the last character in your command text.

Then your example fails with a syntax error.   I think I gave you this example, sorry.

Try

delimiter ??
create procedure test()
begin
declare x tinyint;
select count(*) from person into x;
if x = 2
then
  select * from trip;
end if;
end??
delimiter ; 

*with* the extra space at the end.

Actually, you don't need to say 'delimiter ;' at the end if you're not going to run any more SQL after declaring stored
proc.
Comment 4 David Vancouvering 2008-04-16 16:34:39 UTC
You can validate the stored proc is there by opening up the Procedures node for the connection...
Comment 5 David Vancouvering 2008-04-22 01:18:41 UTC
http://hg.netbeans.org/main?cmd=changeset;node=81cf7bae4006
Comment 6 Roman Mostyka 2008-04-22 15:04:45 UTC
Verified with trunk build 080422. Do push into patch1 branch.
Comment 7 pgebauer 2008-04-28 21:41:44 UTC
The fix has been ported into the release61_fixes branch:

http://hg.netbeans.org/release61_fixes/rev/9d5bff554439