Help needed understanding this connection
I am trying to follow some previous written code to understand JDBC better. When i have previously connected to a database, i have created a connection and then called it up when needed. In this code i have found though, they seem to use somthing called a datasource?
public static Connection getXADBConnection() { Connection conn = null; DataSource ds = null; try { Object obj = lookup(MovieConstants.MOVIE_XA_DATASOURCE_NAME); ds = (DataSource) narrow(obj, DataSource.class); conn = ds.getConnection(); } catch (SQLException ex) { throw new DAORuntimeException(ex); } return conn; }
So is datasource a connection already provided?? If so, is it better to use a datasource or to register through a driver manager? Also, if its not too much to ask, i am struggling to understand the first two lines in the try loop, what exactly is this doing?
cheers
nick2price wrote:
...try loop...Unless that was a typo, I think you should put off learning JDBC for a while and start with the basics.
Start here:
[http://java.sun.com/docs/books/tutorial/]
Similar Messages
-
I try to sync my nano and get: the ipod cant be synced because there is not enough free space to hold all of the items in the items library (need 100MB) - I have a new computer?? can you help me understand this message: what to do?
Hello pryan1012,
What this message means is that you have more music in your itunes library than there is free space in your ipod.
I had this same issue at one time. This is what helped me put my music on the ipod. I used manually manage.
Learn how to sync muisc here.
Hope this helps.
~Julian -
CrashReporter - Could you please help to understand this crash report?
Could you please help to understand this crash report below?
If I'm not wrong it started after update the Mac OS X to version 10.5.6 - every startup.
Note: First update by regular update then after by combo.
Thanks in advance!
_ CrashReporter
Process: aslmanager [218]
Path: /usr/sbin/aslmanager
Identifier: aslmanager
Version: ??? (???)
Code Type: X86 (Native)
Parent Process: launchd [1]
Date/Time: 2009-04-05 08:29:52.069 -0300
OS Version: Mac OS X 10.5.6 (9G55)
Report Version: 6
Exception Type: EXCBADACCESS (SIGSEGV)
Exception Codes: KERNINVALIDADDRESS at 0x0000000000200000
Crashed Thread: 0
Thread 0 Crashed:
0 libSystem.B.dylib 0x952a8a85 asl_get64 + 11
1 libSystem.B.dylib 0x952aa034 aslfile_fetchpos + 939
2 libSystem.B.dylib 0x952aa2f6 aslfilematch + 339
3 aslmanager 0x00002409 0x1000 + 5129
4 aslmanager 0x00002b3e 0x1000 + 6974
5 aslmanager 0x0000211a 0x1000 + 4378
Thread 0 crashed with X86 Thread State (32-bit):
eax: 0x001ffffc ebx: 0x952a9ca1 ecx: 0x00000000 edx: 0x00000000
edi: 0x0000ff3d esi: 0x00100b30 ebp: 0xbffffbc8 esp: 0xbffffba0
ss: 0x0000001f efl: 0x00010286 eip: 0x952a8a85 cs: 0x00000017
ds: 0x0000001f es: 0x0000001f fs: 0x00000000 gs: 0x00000037
cr2: 0x00200000
Binary Images:
0x1000 - 0x2ffd +aslmanager ??? (???) <201b2dea48b8d80ac1432ff85244ed31> /usr/sbin/aslmanager
0x8fe00000 - 0x8fe2db43 dyld 97.1 (???) <100d362e03410f181a34e04e94189ae5> /usr/lib/dyld
0x9444a000 - 0x9444efff libmathCommon.A.dylib ??? (???) /usr/lib/system/libmathCommon.A.dylib
0x951a4000 - 0x951abfe9 libgcc_s.1.dylib ??? (???) <f53c808e87d1184c0f9df63aef53ce0b> /usr/lib/libgcc_s.1.dylib
0x951ba000 - 0x95321ff3 libSystem.B.dylib ??? (???) <d68880dfb1f8becdbdac6928db1510fb> /usr/lib/libSystem.B.dylib
0xffff0000 - 0xffff1780 libSystem.B.dylib ??? (???) /usr/lib/libSystem.B.dylib
_ Log
05/04/09 8:25:58 com.apple.loginwindow[35] Shutdown NOW!
05/04/09 8:25:58 com.apple.loginwindow[35] System shutdown time has arrived
05/04/09 8:25:58 com.apple.SystemStarter[30] Stopping Missing Sync Listener
05/04/09 8:25:58 com.apple.SystemStarter[30] Stopping HP Trap Monitor
05/04/09 8:25:58 com.apple.SystemStarter[30] Stopping HP IO Monitor
05/04/09 8:25:59 com.apple.SystemStarter[30] kextunload: unload kext /System/Library/Extensions/Pvsnet.kext succeeded
05/04/09 8:25:59 com.apple.SystemStarter[30] kextunload: unload kext /System/Library/Extensions/ConnectUSB.kext succeeded
05/04/09 8:26:02 com.apple.SystemStarter[30] kextunload: unload kext /System/Library/Extensions/vmmain.kext succeeded
05/04/09 8:26:02 com.apple.SystemStarter[30] kextunload: unload kext /System/Library/Extensions/hypervisor.kext succeeded
05/04/09 8:26:35 com.apple.launchctl.System[2] BootCacheControl: could not open /var/db/BootCache.playlist: No such file or directory
05/04/09 8:26:35 com.apple.launchctl.System[2] BootCacheControl: could not unlink playlist /var/db/BootCache.playlist: Unknown error: -1
05/04/09 8:26:37 com.apple.launchctl.System[2] launchctl: Please convert the following to launchd: /etc/mach_init.d/dashboardadvisoryd.plist
05/04/09 8:26:37 com.apple.launchd[1] (com.apple.blued) Unknown key for boolean: EnableTransactions
05/04/09 8:26:37 com.apple.launchd[1] (org.cups.cupsd) Unknown key: SHAuthorizationRight
05/04/09 8:26:37 com.apple.launchd[1] (org.ntp.ntpd) Unknown key: SHAuthorizationRight
05/04/09 8:26:49 org.ntp.ntpd[27] Error : nodename nor servname provided, or not known
05/04/09 8:26:57 com.apple.SystemStarter[30] Starting up Missing Sync Listener
05/04/09 8:26:57 com.apple.SystemStarter[30] Starting HP IO Monitor
05/04/09 8:26:58 com.apple.SystemStarter[30] kextload: extension /System/Library/Extensions/hypervisor.kext is already loaded
05/04/09 8:26:58 com.apple.SystemStarter[30] Starting HP Trap Monitor
05/04/09 8:26:58 com.apple.SystemStarter[30] kextload: extension /System/Library/Extensions/vmmain.kext is already loaded
05/04/09 8:26:59 com.apple.SystemStarter[30] kextload: extension /System/Library/Extensions/ConnectUSB.kext is already loaded
05/04/09 8:27:00 com.apple.SystemStarter[30] kextload: extension /System/Library/Extensions/Pvsnet.kext is already loaded
05/04/09 8:27:00 com.apple.SystemStarter[30] kextload: /Library/StartupItems/Parallels/Pvsvnic.kext loaded successfully
05/04/09 8:27:06 com.apple.SystemStarter[30] Sun Apr 5 08:27:06 wslys-Mac.local Missing Sync Listener[77] <Warning>: 3891612: (CGSLookupServerRootPort) Untrusted apps are not allowed to connect to or launch Window Server before login.
05/04/09 8:27:06 com.apple.SystemStarter[30] Sun Apr 5 08:27:06 wslys-Mac.local Missing Sync Listener[77] <Error>: kCGErrorRangeCheck : On-demand launch of the Window Server is allowed for root user only.
05/04/09 8:27:06 com.apple.SystemStarter[30] Sun Apr 5 08:27:06 wslys-Mac.local Missing Sync Listener[77] <Error>: kCGErrorRangeCheck : Set a breakpoint at CGErrorBreakpoint() to catch errors as they are returned
05/04/09 8:27:08 com.apple.SystemStarter[30] _RegisterApplication(), FAILED TO establish the default connection to the WindowServer, _CGSDefaultConnection() is NULL.
05/04/09 8:27:20 com.apple.launchd[1] (com.apple.UserEventAgent-LoginWindow[123]) Exited: Terminated
05/04/09 8:27:20 com.apple.launchctl.Aqua[129] launchctl: Please convert the following to launchd: /etc/machinit_peruser.d/RemoteUI.plist
05/04/09 8:27:20 com.apple.launchd[116] (com.apple.AirPortBaseStationAgent) Unknown key for boolean: EnableTransactions
05/04/09 8:27:21 com.apple.FolderActions.enabled[130] launchctl: Error unloading: com.apple.FolderActions.folders
05/04/09 8:27:42 quicklookd[146] [QL ERROR] 'Creating thumbnail' timed out for '<QLThumbnailRequest /Users/wsly/Downloads/m090374535329zdwg_650ref.mov>'
05/04/09 8:27:42 Dock[138] [QL ERROR] quicklookd crashed while thumbnailing /Users/wsly/Downloads/m090374535329zdwg_hdref.mov
05/04/09 8:29:52 com.apple.launchd[1] (com.apple.aslmanager[218]) Exited abnormally: Segmentation faultTry repairing the disk through the Mac OS X install disk.
-
Help needed with this form in DW
Hi, i have created this form in dreamweaver but ive got this problem.
In the fields above the text field, the client needs to fill in some info such as name, email telephone number etc.
But the problem is when ill get the messages. Only the text from the large text field is there.
What did i do wrong??
http://www.hureninparamaribo.nl/contact.html
Thank you
Anybody??Thank you for your response. So what do i have to do to fix this?
Date: Sun, 20 Jan 2013 07:57:56 -0700
From: [email protected]
To: [email protected]
Subject: Help needed with this form in DW
Re: Help needed with this form in DW
created by Ken Binney in Dreamweaver General - View the full discussion
You have several duplicate "name" attributes in these rows which also appears in the first row
Telefoon:
Huurperiode:
Aantal personen:
Please note that the Adobe Forums do not accept email attachments. If you want to embed a screen image in your message please visit the thread in the forum to embed the image at http://forums.adobe.com/message/5008247#5008247
Replies to this message go to everyone subscribed to this thread, not directly to the person who posted the message. To post a reply, either reply to this email or visit the message page: http://forums.adobe.com/message/5008247#5008247
To unsubscribe from this thread, please visit the message page at http://forums.adobe.com/message/5008247#5008247. In the Actions box on the right, click the Stop Email Notifications link.
Start a new discussion in Dreamweaver General by email or at Adobe Community
For more information about maintaining your forum email notifications please go to http://forums.adobe.com/message/2936746#2936746. -
Hi Pls help me understand this problem
Hi,
I know its a weired doubt, i select (select empno,ename,sal,deptno from emp where ename = 'SMITH')
Result what i have is
EMPNO ENAME SAL DEPTNO
7369 SMITH 800 20
I copied the result from the sql*plus and pasted the same into the same tool,
SQL> EMPNO ENAME SAL DEPTNO
SP2-0734: unknown command beginning "EMPNO ENAM..." - rest of line ignored.
SQL> ------ ---------- ---------- ----------
SQL> 7369 SMITH 800 20
SQL>|
For first copyied line i got error message: SP2-0734: unknown command beginning "EMPNO ENAM..." - rest of line ignored. And for second line i did not get error why ? could any one help me understand this.
Thanks in advance
Mahesh RagineniHi,
The first line from
EMPNO ENAME SAL DEPTNO
7369 SMITH 800 20
is treated as sql statement and gave the error.
the second line is treated as comment hence no error;
In the third line as the line begin with the number
and followed by text it is treated as the sql statement to be added at the given line hence no error. if the first field was not number you will receive error.
for ex:- SMITH 7369 800 20 will give u error.
try this when u get sql prompt after
7369 SMITH 600 20
press / and press enter(to execute the 7369 SMITH 600 20)
then u will receive error.
Regs
Dhananjaya -
Pls help to understand this routine program
Pls help to understand this routine program written in transformation level for a field.
Data a Type /bic/oizsnote_2.
Data: l_len type i,
l_time type i.
Move source_fields-zztdline+60(60) TO a.
l_len = STRLEN(a).
DO l_len TIMES.
IF a+l_time(1) CN
',<>?/:;"''ABCDEFGHIJKLMNOPQTRSTUVWXYZ abcdefghijklmnopqrstuvwxyz!%^&' & '*' & "()__+=12346567890'
a+l_time(1) = '~'.
Endif.
l_time = l_time + 1.
enddo.
replace all occurrences of '~' in a with space.
Result = a.
not having much exposure in ABAP programming.
RajIn addition to the above to posts..
HI Raj,
Your routine is used to remove the invalid characters.
IF A+l_time(1) CN
A is a Char which contains the data .*
I_time is used for iteration(itu2019ll check each char by char in a word/Sentence).
*CN u2013 Contains not
,?/:;"''ABCDEFGHIJKLMNOPQTRSTUVWXYZ abcdefghijklmnopqrstuvwxyz!%^&' & '*' & "()__+=12346567890.
These are the Valid chars and numbers which will be accepted by BW system, System will throw an error only when load receives a char which is not there in the above. And that char will be treated as a Invalid Char.
A+l_time(1) = '~'.
What ever the special/Invalid char appears in the load apart from the above mentioned, system will convert them to u2018~u2019
REPLACE ALL OCCURRENCES OF '~' IN a WITH space.
CONDENSE A.
System will replace all the ~ with space, then condenses the space.
You can do this using RSKC transaction instead of going for routine. -
Urgent help in understanding this
Hi
I have the attached Vi. Ths VI generate six different number between 0 and 45 i dont understand very well the logic of program. I dont understand the input of shift register []DBL. is it in funtions palette?
I would like that you help to understand this program.
Attachments:
Array of Random Numbers (LV 2009) (1).vi 11 KBThe input to the shift register is an empty array for double floating point numbers.
I don't know if you;ve been pointed to this before, but I would highly recommend looking at the online LabVIEW tutorials
LabVIEW Introduction Course - Three Hours
LabVIEW Introduction Course - Six Hours
And please give a more descriptive subject line then "urgent help in understand this". -
I have turned off the Data use on the I-phone 4s but am told by AT&T that data is still being used for applications. How is this possible. Can someone help me understand this.
I assume you are including the STIX font as part of your epub files?
Perhaps the folks who do this blog might be able to help -- they have done some work with font embedding:
http://www.pigsgourdsandwikis.com/2011/04/embedding-fonts-in-epub-ipad-iphone-an d.html -
Help to understand this question.
for(int i = 1; i < 22; i++)
if(i % 5 == 0 || i % 2 != 0 && i % 3 == 0)
System.out.print(i + ? ?);
I already know the answer this (3 5 9 10 15 20 21) but I do not understand how come..Can you help me understand this?In this program the and(&&) operator takes precedence among all opertors so, the "If" condition evalutes by considering && opertion first then || operation.,i.e. when i=3 the condition holds true(i % 2 !=0 && i %3==0). i think u can understand the logic now.
-
Can someone please help me understand this? About Apple Repairs
Hello everyone,
I bought my macbook in Nov. 2009 in USA. I just moved to India and I've noticed the rubber base coming off and the infamous apple hairline crack. When I first took it to the India center, they kept insisting I had to pay for repair, I have a 1 year limited warranty.
Upon my insisting that they check with Apple USA first, they decided to call them and then asked me to send them pictures. I've sent the pictures, my repairs have been approved.
Now they tell me that I need to bring in the laptop and they need to run some software test for the crack, then they will submit this test and get the screen in about 4-5 days and then return the mac to me.
I need to understand this from people that have gone through this sort of repair. Why do they need to do a software test for a hardware issue?
Even if they have to do this software test, why can't they wait till the screen arrives (as this is the only way they claim to fix the crack) and then do the test all at once in one single day, rather than making me run back and forth with my macbook?
I also requested for them to forward Apple's response to me, they refused and said its internal.
I would really appreciate it if someone can please explain this to me, as the logic is just not making sense in my head. Maybe this is the way they do repairs and I'm not aware of them.. don't know..
Thanks everyone!!ok running it through a debugger DID NOT HELP at all, please somebody help me, im very desparate now. i have spent 15 hours on this problem alone. i see absolutley nothing wrong with my code and have tried about 10 doifferent ways of trying this.,....i cannot get it to work, somebody please help me, ...in addition i was hoping someone could clear up an issue i have with enums...i do not understand how i can access the variable of the enum, the only access to it my text book provides is how to acess the string associated with enums....but i need to access the variable itself...how would i design such a get method....ive tried that a bunch of different ways as well, and right now im so lost that i want to cry, somebody please help, im begging on my knees...i really need someone to explain this to me....
-
Help needed:MBP net connection slow on OSX but fast on Vista...
Ok..I've searched these forums for a while, seen lots of posts taking about people having problems with their airport card, routers and the like..but I haven't seen anyone having quite the same problem as me. My 17" 2.33Ghz C2D is linked to my 1Mb ADSL internet connection via an Aztech DSL600EW modem router.The problem is that the connection speed is really slow when I'm running the machine on OSX. I know it's an OSX thing cos the same machine,connected to the same router and running Windows Vista via Bootcamp will connect to the net ALOT faster. For example, if I'm viewing videos on youtube with OSX, I have to wait every few seconds for the video to buffer, but on Vista, the buffering is way ahead of the video. Another example would be downloading files...say from rapidshare. The typical download speed I get on OSX would be around 5-10Kbps, but with Vista, I get at least 25Kbps.
I'm quite new to OSX, and still trying to learn my way around the operating system. It seems such a pity for a really great machine with a really great operating system to be let down by slow internet connection. I hope someone out there will be able to help me sort this out. Thanks in advance.Great, happy that it "seems to speed up things ..." Why not run the SpeedTest and "know?"
I use IPNetTuner ($30, free 21 day trial).
http://www.sustworks.com/site/prodiptxoverview.html
"*Why is it Sometimes Necessary To Tune TCP/IP*?
TCP/IP is not controlled by any manufacturer and is designed to work on almost any kind of underlying network with widely varying characteristics.
To meet this challenge, the protocol designers made TCP adaptive. TCP is self monitoring and optimizes its own behavior to match the network environment.
*Why can't somebody just write a utility that analyzes my network and automatically selects the optimum settings?* Such a tool would be both useful and popular. The answer is they already have, it's called TCP/IP, but sometimes it needs a little help.
In most cases, TCP works remarkably well all by itself. Tuning is needed in those cases where TCP doesn't quite get it right because the the network behavior is outside the expected range. Typical problems include:
Asymmetric connections that are much faster downstream than upstream.
High performance connections with relatively long latency ..." -
Hi guys, I need help in debugging this code I made, which is a GUI minesweeper. Its extremely buggy...I particularly need help fixing the actionListener part of the code as everytime I press a button on the GUI, an exception occurs.
help please!
package minesweeperGUI;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class MinesweeperGUI implements ActionListener
//Declaration of attributes
static int length = 0;
JMenuItem menuItemNew = new JMenuItem();
JRadioButtonMenuItem rbEasy = new JRadioButtonMenuItem();
JRadioButtonMenuItem rbHard = new JRadioButtonMenuItem();
JMenuItem menuItemExit = new JMenuItem();
JButton buttonReset = new JButton();
JButton buttonGrid[][] = null;
JFrame frame = new JFrame();
int getBombsTotal = 0;
JLabel setBombsLabel = new JLabel();
int a = 0;
int b = 0;
//No constructor created. Uses default constructor
//Create the menu bar
public JMenuBar newMenuBar()
//Sets up the menubar
JMenuBar menuBar = new JMenuBar();
//Sets up the Game menu with choice of new, grid size, and exit
JMenu menu = new JMenu ("Game");
menuBar.add (menu);
menuItemNew = new JMenuItem ("New");
menuItemNew.addActionListener (this);
menu.add (menuItemNew);
menu.addSeparator();
//Sets up sub-menu for grid size with choice of easy and hard radio buttons
JMenu subMenu = new JMenu ("Grid Size");
rbEasy = new JRadioButtonMenuItem ("Easy: 5x5 grid");
rbEasy.addActionListener (this);
subMenu.add (rbEasy);
rbHard = new JRadioButtonMenuItem ("Hard: 10x10 grid");
rbHard.addActionListener (this);
subMenu.add (rbHard);
menu.add (subMenu);
menu.addSeparator();
menuItemExit = new JMenuItem ("Exit");
menuItemExit.addActionListener (this);
menu.add (menuItemExit);
return menuBar;
//Setting up of Bomb Grid
public int [][] setGrid (int length)
int grid[][] = null;
grid = new int[length][length];
for (int i = 0; i < length; i++)
for (int j = 0; j < length; j++)
grid[i][j] = ((int)Math.round(Math.random() * 10))% 2;
return grid;
//Setting up of the of the graphical bomb grid
public JButton[][] setButtonGrid (int length)
JButton buttonGrid[][] = null;
buttonGrid = new JButton[length][length];
for (int i = 0; i < length; i++)
for (int j = 0; j < length; j++)
buttonGrid[i][j] = new JButton();
return buttonGrid;
//Setting up of a way to count the total number of bombs in the bomb grid
public int getBombsTotal (int length, int setGrid[][])
int bombsTotal = 0;
for (int i = 0; i < length; i++)
for (int j = 0; j < length; j++)
if (setGrid[i][j] == 1)
bombsTotal += 1;
return bombsTotal;
//Create a label for number of bombs left
public JLabel setBombsLabel (int getBombsTotal)
JLabel bombsLabel = new JLabel(String.valueOf (getBombsTotal) + " Bombs Left");
return bombsLabel;
//Setting up a way to count the number of bombs around a button
public String setBombs (int length, int setGrid[][], int x, int y)
int bombs[][] = new int[length][length];
String bombsString = null;
for (int i = 0; i < length; i++)
for (int j = 0; j < length; j++)
if (i == 0 && j == 0)
bombs[i][j] = setGrid[i][j+1] + setGrid[i+1][j] +
setGrid[i+1][j+1];
else if (i ==0 && j == (length - 1))
bombs[i][j] = setGrid[i][j-1] + setGrid[i+1][j-1] +
setGrid[i+1][j];
else if (i == (length - 1) && j == 0)
bombs[i][j] = setGrid[i-1][j] + setGrid[i-1][j+1] +
setGrid[i][j+1];
else if (i == (length - 1) && j == (length - 1))
bombs[i][j] = setGrid[i-1][j-1] + setGrid[i-1][j] +
setGrid[i][j-1];
else if (i == 0 && j != 0 && j != (length - 1))
bombs[i][j] = setGrid[i][j-1] + setGrid[i][j+1] +
setGrid[i+1][j-1] + setGrid[i+1][j] +
setGrid[i+1][j+1];
else if (i == (length - 1) && j != 0 && j != (length - 1))
bombs[i][j] = setGrid[i-1][j-1] + setGrid[i-1][j] +
setGrid[i-1][j+1] + setGrid[i][j-1] +
setGrid[i][j+1];
else if (i != 0 && i != (length - 1) && j == 0)
bombs[i][j] = setGrid[i-1][j] + setGrid[i-1][j+1] +
setGrid[i][j+1] + setGrid[i+1][j] +
setGrid[i+1][j+1];
else if (i != 0 && i != (length - 1) && j == (length - 1))
bombs[i][j] = setGrid[i-1][j-1] + setGrid[i-1][j] +
setGrid[i][j-1] + setGrid[i+1][j-1] +
setGrid[i+1][j];
else
bombs[i][j] = setGrid[i-1][j-1] + setGrid[i-1][j] +
setGrid[i-1][j+1] + setGrid[i][j-1] +
setGrid[i][j+1] + setGrid[i+1][j-1] +
setGrid[i+1][j] + setGrid[i+1][j+1];
bombsString = String.valueOf (bombs[x][y]);
return bombsString;
//create the panel for the bombs label and reset button
public JPanel newTopPanel(int length)
int setGridNew [][] = null;
setGridNew = new int[length][length];
int getBombsTotalNew = 0;
JLabel setBombsLabelNew = new JLabel();
setGridNew = setGrid (length);
getBombsTotalNew = getBombsTotal (length, setGridNew);
setBombsLabelNew = setBombsLabel (getBombsTotalNew);
JPanel topPanel = new JPanel ();
topPanel.setLayout (new BorderLayout (50,50));
JLabel bombsLabel = new JLabel ();
bombsLabel = setBombsLabelNew;
topPanel.add (bombsLabel, BorderLayout.WEST);
buttonReset = new JButton("Reset");
buttonReset.addActionListener (this);
topPanel.add (buttonReset, BorderLayout.CENTER);
return topPanel;
//create the panel for the play grids
public JPanel newBottomPanel(int length)
JButton setButtonGridNew[][] = null;
setButtonGridNew = new JButton [length][length];
setButtonGridNew = setButtonGrid (length);
JPanel bottomPanel = new JPanel ();
bottomPanel.setLayout (new GridLayout (length, length));
buttonGrid = new JButton[length][length];
for (a = 0; a < length; a++)
for (b = 0; b < length; b++)
buttonGrid[a] = setButtonGridNew[a][b];
buttonGrid[a][b].addActionListener (this);
bottomPanel.add (buttonGrid[a][b]);
return bottomPanel;
//Overiding of abstract method actionPerformed
public void actionPerformed(ActionEvent e)
if (e.getSource() == menuItemNew)
launchFrame(length);
else if (e.getSource() == menuItemExit)
frame.setVisible (false);
System.exit(0);
else if (e.getSource() == rbEasy)
length = 5;
launchFrame(length);
else if (e.getSource() == rbHard)
length = 10;
launchFrame(length);
else if (e.getSource() == buttonReset)
launchFrame(length);
else if (e.getSource() == buttonGrid[a][b])
int setGridNew [][] = null;
setGridNew = new int[length][length];
JButton bombButton [][] = null;
bombButton = new JButton [length][length];
String bombString [][] = null;
bombString = new String[length][length];
setGridNew = setGrid (length);
bombString[a][b] = setBombs (length, setGridNew, a, b);
bombButton[a][b] = new JButton (bombString[a][b]);
if (setGridNew[a][b] == 0)
buttonGrid[a][b] = bombButton[a][b];
getBombsTotal--;
JLabel setBombsLabelNew = new JLabel();
setBombsLabelNew = setBombsLabel (getBombsTotal);
else if (setGridNew[a][b] == 1 )
buttonGrid[a][b] = new JButton("x");
JOptionPane.showMessageDialog (null, "Game Over. You hit a Bomb!");
System.exit(0);
//create the content pane
public Container newContentPane(int length)
JPanel topPanel = new JPanel();
JPanel bottomPanel = new JPanel();
topPanel = newTopPanel(length);
bottomPanel = newBottomPanel (length);
JPanel contentPane = new JPanel();
contentPane.setOpaque (true);
contentPane.setLayout (new BorderLayout(50,50));
contentPane.add (topPanel, BorderLayout.NORTH);
contentPane.add (bottomPanel, BorderLayout.CENTER);
return contentPane;
public void launchFrame (int length)
//Makes sure we have nice window decorations
JFrame.setDefaultLookAndFeelDecorated(true);
//Sets up the top-level window
frame = new JFrame ("Minesweeper");
//Exits program when the closed button is clicked
frame.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
JMenuBar menuBar = new JMenuBar();
Container contentPane = new Container();
menuBar = newMenuBar();
contentPane = newContentPane (length);
//Sets up the menu bar and content pane
frame.setJMenuBar (menuBar);
frame.setContentPane (contentPane);
//Displays the window
frame.pack();
frame.setVisible (true);
public static void main (String args[])
//Default length is 5
length = 5;
MinesweeperGUI minesweeper = new MinesweeperGUI();
minesweeper.launchFrame(length);hi, thanks. that removed the exception; although now the buttons action listener won't work :(
here is the revised code:
To anyone out there, can you guys run this code and help me debug it?
I'm really desperate as this is a school project of mine and the deadline is 7 hours away. I have already been working on it for 3 days, but the program is still very buggy.
thanks!
/* Oliver Ian C. Wee 04-80112
* CS12 MHRU
* Machine Problem 2
package minesweeperGUI;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class MinesweeperGUI implements ActionListener
//Declaration of attributes
static int length = 0;
JMenuItem menuItemNew = new JMenuItem();
JRadioButtonMenuItem rbEasy = new JRadioButtonMenuItem();
JRadioButtonMenuItem rbHard = new JRadioButtonMenuItem();
JMenuItem menuItemExit = new JMenuItem();
JButton buttonReset = new JButton();
JButton buttonGrid[][] = null;
JFrame frame = new JFrame();
int getBombsTotal = 0;
JLabel setBombsLabel = new JLabel();
int a = 0;
int b = 0;
//No constructor created. Uses default constructor
//Create the menu bar
public JMenuBar newMenuBar()
//Sets up the menubar
JMenuBar menuBar = new JMenuBar();
//Sets up the Game menu with choice of new, grid size, and exit
JMenu menu = new JMenu ("Game");
menuBar.add (menu);
menuItemNew = new JMenuItem ("New");
menuItemNew.addActionListener (this);
menu.add (menuItemNew);
menu.addSeparator();
//Sets up sub-menu for grid size with choice of easy and hard radio buttons
JMenu subMenu = new JMenu ("Grid Size");
ButtonGroup bg = new ButtonGroup();
rbEasy = new JRadioButtonMenuItem ("Easy: 5x5 grid");
bg.add (rbEasy);
rbEasy.addActionListener (this);
subMenu.add (rbEasy);
rbHard = new JRadioButtonMenuItem ("Hard: 10x10 grid");
bg.add (rbHard);
rbHard.addActionListener (this);
subMenu.add (rbHard);
menu.add (subMenu);
menu.addSeparator();
menuItemExit = new JMenuItem ("Exit");
menuItemExit.addActionListener (this);
menu.add (menuItemExit);
return menuBar;
//Setting up of Bomb Grid
public int [][] setGrid (int length)
int grid[][] = null;
grid = new int[length][length];
for (int i = 0; i < length; i++)
for (int j = 0; j < length; j++)
grid[i][j] = ((int)Math.round(Math.random() * 10))% 2;
return grid;
//Setting up of the of the graphical bomb grid
public JButton[][] setButtonGrid (int length)
JButton buttonGrid[][] = null;
buttonGrid = new JButton[length][length];
for (int i = 0; i < length; i++)
for (int j = 0; j < length; j++)
buttonGrid[i][j] = new JButton();
return buttonGrid;
//Setting up of a way to count the total number of bombs in the bomb grid
public int getBombsTotal (int length, int setGrid[][])
int bombsTotal = 0;
for (int i = 0; i < length; i++)
for (int j = 0; j < length; j++)
if (setGrid[i][j] == 1)
bombsTotal += 1;
return bombsTotal;
//Create a label for number of bombs left
public JLabel setBombsLabel (int getBombsTotal)
JLabel bombsLabel = new JLabel(" " +String.valueOf (getBombsTotal) + " Bombs Left");
return bombsLabel;
//Setting up a way to count the number of bombs around a button
public String setBombs (int length, int setGrid[][], int x, int y)
int bombs[][] = new int[length][length];
String bombsString = null;
for (int i = 0; i < length; i++)
for (int j = 0; j < length; j++)
if (i == 0 && j == 0)
bombs[i][j] = setGrid[i][j+1] + setGrid[i+1][j] +
setGrid[i+1][j+1];
else if (i ==0 && j == (length - 1))
bombs[i][j] = setGrid[i][j-1] + setGrid[i+1][j-1] +
setGrid[i+1][j];
else if (i == (length - 1) && j == 0)
bombs[i][j] = setGrid[i-1][j] + setGrid[i-1][j+1] +
setGrid[i][j+1];
else if (i == (length - 1) && j == (length - 1))
bombs[i][j] = setGrid[i-1][j-1] + setGrid[i-1][j] +
setGrid[i][j-1];
else if (i == 0 && j != 0 && j != (length - 1))
bombs[i][j] = setGrid[i][j-1] + setGrid[i][j+1] +
setGrid[i+1][j-1] + setGrid[i+1][j] +
setGrid[i+1][j+1];
else if (i == (length - 1) && j != 0 && j != (length - 1))
bombs[i][j] = setGrid[i-1][j-1] + setGrid[i-1][j] +
setGrid[i-1][j+1] + setGrid[i][j-1] +
setGrid[i][j+1];
else if (i != 0 && i != (length - 1) && j == 0)
bombs[i][j] = setGrid[i-1][j] + setGrid[i-1][j+1] +
setGrid[i][j+1] + setGrid[i+1][j] +
setGrid[i+1][j+1];
else if (i != 0 && i != (length - 1) && j == (length - 1))
bombs[i][j] = setGrid[i-1][j-1] + setGrid[i-1][j] +
setGrid[i][j-1] + setGrid[i+1][j-1] +
setGrid[i+1][j];
else
bombs[i][j] = setGrid[i-1][j-1] + setGrid[i-1][j] +
setGrid[i-1][j+1] + setGrid[i][j-1] +
setGrid[i][j+1] + setGrid[i+1][j-1] +
setGrid[i+1][j] + setGrid[i+1][j+1];
bombsString = String.valueOf (bombs[x][y]);
return bombsString;
//create the panel for the bombs label and reset button
public JPanel newTopPanel(int length)
int setGridNew [][] = null;
setGridNew = new int[length][length];
int getBombsTotalNew = 0;
JLabel setBombsLabelNew = new JLabel();
setGridNew = setGrid (length);
getBombsTotalNew = getBombsTotal (length, setGridNew);
setBombsLabelNew = setBombsLabel (getBombsTotalNew);
JPanel topPanel = new JPanel ();
topPanel.setLayout (new BorderLayout (20,20));
JLabel bombsLabel = new JLabel ();
bombsLabel = setBombsLabelNew;
topPanel.add (bombsLabel, BorderLayout.WEST);
buttonReset = new JButton("Reset");
buttonReset.addActionListener (this);
topPanel.add (buttonReset, BorderLayout.CENTER);
return topPanel;
//create the panel for the play grids
public JPanel newBottomPanel(int length)
JButton setButtonGridNew[][] = null;
setButtonGridNew = new JButton [length][length];
setButtonGridNew = setButtonGrid (length);
JPanel bottomPanel = new JPanel ();
bottomPanel.setLayout (new GridLayout (length, length));
buttonGrid = new JButton[length][length];
for (int i = 0; i < length; i++)
for (int j = 0; j < length; j++)
buttonGrid[i][j] = setButtonGridNew[i][j];
buttonGrid[i][j].addActionListener (this);
bottomPanel.add (buttonGrid[i][j]);
return bottomPanel;
//Overiding of abstract method actionPerformed
public void actionPerformed(ActionEvent e)
if (e.getSource() == menuItemNew)
closeFrame();
launchFrame(length);
else if (e.getSource() == menuItemExit)
frame.setVisible (false);
System.exit(0);
else if (e.getSource() == rbEasy)
closeFrame();
length = 5;
launchFrame(length);
else if (e.getSource() == rbHard)
closeFrame();
length = 10;
launchFrame(length);
else if (e.getSource() == buttonReset)
closeFrame();
launchFrame(length);
else if (e.getSource() == buttonGrid[a])
int setGridNew [][] = null;
setGridNew = new int[length][length];
JButton bombButton [][] = null;
bombButton = new JButton [length][length];
String bombString [][] = null;
bombString = new String[length][length];
setGridNew = setGrid (length);
for (int i = 0; i < length; i++)
for (int j = 0; j < length; j++)
bombString[i][j] = setBombs (length, setGridNew, i, j);
bombButton[i][j] = new JButton (bombString[i][j]);
if (setGridNew[a][b] == 0)
buttonGrid[a][b] = bombButton[a][b];
getBombsTotal--;
JLabel setBombsLabelNew = new JLabel();
setBombsLabelNew = setBombsLabel (" " String.valueOf (getBombsTotal) " Bombs Left");
else if (setGridNew[a][b] == 1 )
buttonGrid[a][b] = new JButton("x");
JOptionPane.showMessageDialog (null, "Game Over. You hit a Bomb!");
System.exit(0);
//create the content pane
public Container newContentPane(int length)
JPanel topPanel = new JPanel();
JPanel bottomPanel = new JPanel();
topPanel = newTopPanel(length);
bottomPanel = newBottomPanel (length);
JPanel contentPane = new JPanel();
contentPane.setOpaque (true);
contentPane.setLayout (new BorderLayout(5,5));
contentPane.add (topPanel, BorderLayout.NORTH);
contentPane.add (bottomPanel, BorderLayout.CENTER);
return contentPane;
public void closeFrame ()
frame = new JFrame ("Minesweeper");
frame.dispose();
public void launchFrame (int length)
//Makes sure we have nice window decorations
JFrame.setDefaultLookAndFeelDecorated(true);
//Sets up the top-level window
frame = new JFrame ("Minesweeper");
//Exits program when the closed button is clicked
frame.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
JMenuBar menuBar = new JMenuBar();
Container contentPane = new Container();
menuBar = newMenuBar();
contentPane = newContentPane (length);
//Sets up the menu bar and content pane
frame.setJMenuBar (menuBar);
frame.setContentPane (contentPane);
//Displays the window
frame.pack();
frame.setVisible (true);
public static void main (String args[])
//Default length is 5
length = 5;
MinesweeperGUI minesweeper = new MinesweeperGUI();
minesweeper.launchFrame(length); -
Urgent Help Needed in this Report
hi frd. help me in this report.
parameter : plant,material no,company code,storage location.
display: material no, material desc, UOM, ROL, warehouse, open po, open po qty, open pr no, open pr qty.
Kindly Give me tips for doing this report.
thank u
Pari Vendhan.RHi Pari,
Go to se38 --Abap editior..
chose the includes u like to be as
Include <>_top.
Include <>_subr.
then follow the events....
Initialization.
( as per requirement).
At selection-screen.
Perform fetch _data.
Perform fefilloutput.
any other logic to be followed for u r report.
end-of-selection.
Perform output.
In include top.
Put the declarartion part and the selection-screen block.
SELECTION SCREEN
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
PARAMETERS : pa_werks LIKE table name-werks
pa_material no like tablename-field.
SELECTION-SCREEN END OF BLOCK b1.
like wise u need to put the logic for the requirement
Thanks
Mohinder Singh Chauhan -
Can somebody help me understand this dialog window?
I have an English CS3 but my native language is Dutch. I struggle understanding this dialog box:
Your current color settings honor CMYK profiles in linked content but profiles were set to be ignored when this document was created
I often get this error when opening downloaded files.
What linked content? Which profiles are ignored. Is this a vital warning?
Thanks,
RonaldMost imporant: set up color management. Synchronize color management across your applications and versions.
If you don't know how to do that, you're in really serious trouble. There's some literature on the topic. Get it and read it. You might start with this:
Adobe publishes a new Creative Suite 5/5.5 Printing Guide - Rufus Deuchler
and the manual. Look for a Lynda.com training or search the web for resources. There's some really good stuff available in German, but I don't know about the English resources (beacause our own are so luxurious).
The dialog box tells you that your settings regarding linked CMYK images were different in your other Illustrator version. You had it set to "Preserve embedded profiles", but now you've set it to "Preserve numbers". Depending on the nature of your files, your workflow, your co-workers' workflows or the printing process both settings might or might not be correct. But most probably changing the settings in the middle of working at the same file is not correct. The setting influences how colors are converted when creating the final output. So, yes, it is important. -
HI ALL,
I have created a queue table and queue as below. i call enqueue procedure in after update of a trigger. With a package variable 'FISCFILE' . When I execute the update Of it it tells invalid queue name . can anyone help me with this
SQL> ed select
SQL> ed select
SQL> SELECT Name FROM User_Queues WHERE Name LIKE '%FISC%';
NAME
AQ$_QT_FISCFILE_E
Q_FISCFILE
SQL>
SQL> SELECT Queue_Table FROM User_Queue_Tables WHERE Queue_Table LIKE '%FISC%';
QUEUE_TABLE
QT_FISCFILE
SQL> Spool Off
Value Of PACKAGE variable:-
Package VARIABLE :='FISCFILE';
UPDATE TL_PYMT_DETAILS
SET PYMT_TYPE ='RTGS',
STATUS_CODE =91,
FISC_STATUS ='N',
PROC_DATE = TRUNC(SYSDATE)
WHERE PYMT_REF ='R0421141' ;
Queue Name :- STS_AQ_ADM.Q_FISCFILE
UPDATE TL_PYMT_DETAILS
ERROR AT line 1:
ORA-20001: QUEUE NAME INVALID PLEASE RERUN WITH CORRECT QUEUE NAME
ORA-06512: AT "STS_TW_DBA.TRG_FISC_GEN", line 16
ORA-04088: error during execution OF TRIGGER 'STS_TW_DBA.TRG_FISC_GEN'Dear All,
Sorry For the delayed reply. The Payload name was given wrong.
Maybe you are looking for
-
Ability to send report in excel format through ibot to mail
Hi, we are using sibel analytics 7.7.1 ,. my requirement is to send report in excel format as attachment through ibots to mails. is it possible in 7.7. Default we can send as plain text, pdf, HTML format we can send the report . We need in excel form
-
Erro while executing query using BWA
Hello BWA experts, I am facing a issue while running a query by using BIA. I get error message as "Program error in class SAPMSSY1 method: UNCAUGHT_EXCEPTIION. My querz contains one basis key figure in the column and a charateristic say company code
-
Duplicate records in Internal table
Hi All, I want to find out the duplicate entry in the internal table. I have used, Delete Adjacent duplicates from itab. It is straight away deleting the record. I want the user to correct that duplicate record. May be some error message. I have trie
-
hi all. Hope someone can help me because I'm getting very frustrated and not finding answers! I am trying to change my billing address in my itunes store account, but itunes is not allowing me to do this. At the bottom of the page, I only get the 'ca
-
hi can any one help me i lost all my ipod purchased songs i downloaded from itunes store is there anyway of getting them back from the purchased history from my account or do i have to download them all again? if i cant i have lost money over it :o(.