Java Game and bounds problem

Hey all,
I created four different backgrounds for a project I am creating. (The background are a top down view of a road with sidewalks). I have them named as road1, road2, road3, and road4.
I have two questions. My first and most important is if I have a little box I want to move around the screen (a character), how do I set bounds so it can't go past a certain point (i.e. the road is the only place it is allowed to go)???
And secondly, I know how to remove panels but if I wanted this to be a long road and once the character reaches the right side of the screen it would remove road1 and replace it with road 2. How would I accomplish this?? And once that is figured out, road 3 would replace road 2, but road 3 goes vertical so the character would go right through road 1 and right through road 2, but vertical through road 3 to get to road 4.
I have a bunch of code if anyone would like to see to help make sense of this, just let me know exactly what you would like to see.
Thanks in advance for all the help and I hope I didn't confuse anyone too much.
P.S. If this has already been discussed, I apologize. I looked, but couldn't find anything.

I created four different backgrounds for a project I
am creating. (The background are a top down view of
a road with sidewalks). I have them named as road1,
road2, road3, and road4.
I have two questions. My first and most important is
if I have a little box I want to move around the
screen (a character), how do I set bounds so it can't
go past a certain point (i.e. the road is the only
place it is allowed to go)???You have a couple of options that I know of--
1 - simple boundary check, your road needs to be straight or mathematically defined so you can check by position.
2 - easier: since you have sidewalks, you have a natural boundary--before you move check to see if the color of pixel is road or sidewalk. if road, then move to it, if sidewalk then do something else.
And secondly, I know how to remove panels but if I
wanted this to be a long road and once the character
reaches the right side of the screen it would remove
road1 and replace it with road 2. How would I
accomplish this?? And once that is figured out, road
3 would replace road 2, but road 3 goes vertical so
the character would go right through road 1 and right
through road 2, but vertical through road 3 to get to
road 4.You have to figure out what type of overlap point you want in each pannel: when you come off of 1 and go to 2 do you want to start on the extream edge or part way through? Once this is done you just need to make a simple adjustment to your location and repaint onto the new panel. Same for when you go to the left side. keep track of what road you are on and implement a conversion from 1 to 2, 2 to 3, 3 to 4, 4 to 1, 3 to 2, and 2 to 1.

Similar Messages

  • I am making code to try to make a game and my problem is that my code......

    I am making code to try to make a game and my problem is that my code
    will not let it change the hit everytime so im getting the first guy to hit 1 then next hits 8 and so on and always repeats.
    Another problem is that I would like it to attack with out me telling it how much times to attack. I am using Object oriented programming.
    Here is the code for my objects:
    import java.lang.*;
    import java.io.*;
    import java.net.*;
    import java.util.*;
    import java.util.Random;
    import static java.lang.Math.*;
    import java.awt.*;
    import java.awt.color.*;
    class rockCrab {
         //Wounding formula
         double sL = 70;                                   // my Strength Level
         double bP = 1;                                   // bonus for prayer (is 1 times prayer bonus)
         double aB = 0;                                 // equipment stats
         double eS = (sL * bP) + 3;                         // effective strength
         double bD = floor(1.3 + (eS/10) + (aB/80) + ((eS*aB)/640));     // my base damage
         //Attack formula
         double aL = 50;                                   // my Attack Level
         double eD = 1;                                   // enemy's Defence
         double eA = aL / eD;                              // effective Attack
         double eB = 0;                                   // equipment bonus'
         double bA = ((eA/10) * (eB/10));                    // base attack
         //The hit formula
         double fA = random() * bA;
         double fH = random() * bD;
         double done = rint(fH - fA);
         //health formula
         double health = floor(10 + sL/10 * aL/10);
         rockCrab() {
         void attack() {
              health = floor(10 + sL/10 * aL/10);
              double done = rint(fH - fA);
              fA = random() * bA;
              fH = random() * bD;
              done = rint(fH - fA);
              System.out.println("Rockcrab hit" +done);
    import java.lang.*;
    import java.io.*;
    import java.net.*;
    import java.util.*;
    import java.util.Random;
    import static java.lang.Math.*;
    import java.awt.*;
    import java.awt.color.*;
    class self {
         //Wounding formula
         double sL = 1;                                   // my Strength Level
         double bP = 1;                                   // bonus for prayer (is 1 times prayer bonus)
         double aB = 0;                                 // equipment stats
         double eS = (sL * bP) + 3;                         // effective strength
         double bD = floor(1.3 + (eS/10) + (aB/80) + ((eS*aB)/640));     // my base damage
         //Attack formula
         double aL = 1;                                   // my Attack Level
         double eD = 1;                                   // enemy's Defence
         double eA = aL / eD;                              // effective Attack
         double eB = 0;                                   // equipment bonus'
         double bA = ((eA/10) * (eB/10));                    // base attack
         //The hit formula
         double fA = random() * bA;
         double fH = random() * bD;
         double done = rint(fH - fA);
         //health formula
         double health = floor(10 + sL/10 * aL/10);
         self() {
         void attack() {
              health = floor(10 + sL/10 * aL/10);
              fA = random() * bA;
              fH = random() * bD;
              done = rint(fH - fA);
              System.out.println("You hit" +done);
    }Here is the main code that writes what the objects do:
    class fight {
         public static void main(String[] args) {
              self instance1 = new self();
              rockCrab instance2 = new rockCrab();
              instance2.health = instance2.health - instance1.done;
              System.out.println("You hit: " +instance1.done);
              System.out.println("rockCrabs health: " + instance2.health);
              instance1.health = instance1.health - instance2.done;
              System.out.println("RockCrab hit: " +instance2.done);
              System.out.println("rockCrabs health: " + instance1.health);
              instance2.health = instance2.health - instance1.done;
              System.out.println("You hit: " +instance1.done);
              System.out.println("rockCrabs health: " + instance2.health);
              instance1.health = instance1.health - instance2.done;
              System.out.println("RockCrab hit: " +instance2.done);
              System.out.println("rockCrabs health: " + instance1.health);
              instance2.health = instance2.health - instance1.done;
              System.out.println("You hit: " +instance1.done);
              System.out.println("rockCrabs health: " + instance2.health);
              instance1.health = instance1.health - instance2.done;
              System.out.println("RockCrab hit: " +instance2.done);
              System.out.println("rockCrabs health: " + instance1.health);
              instance2.health = instance2.health - instance1.done;
              System.out.println("You hit: " +instance1.done);
              System.out.println("rockCrabs health: " + instance2.health);
              instance1.health = instance1.health - instance2.done;
              System.out.println("RockCrab hit: " +instance2.done);
              System.out.println("rockCrabs health: " + instance1.health);
    }when the code is run it says something like this:
    you hit 1
    RockCrabs health is 9
    RockCrab hit 7
    your health is 38
    you hit 1
    RockCrabs health is 8
    RockCrab hit 7
    your health is 31
    you hit 1
    RockCrabs health is 7
    RockCrab hit 7
    your health is 24
    you hit 1
    RockCrabs health is 6
    RockCrab hit 7
    your health is 17
    my point is whatever some one hits it always repeats that
    my expected output would have to be something like
    you hit 1
    RockCrabs health is 9
    RockCrab hit 9
    your health is 37
    you hit 3
    RockCrabs health is 6
    RockCrab hit 4
    your health is 33
    you hit 2
    RockCrabs health is 4
    RockCrab hit 7
    your health is 26
    you hit 3
    RockCrabs health is 1
    RockCrab hit 6
    your health is 20
    Edited by: rade134 on Jun 4, 2009 10:58 AM

    [_Crosspost_|http://forums.sun.com/thread.jspa?threadID=5390217] I'm locking.

  • Just purchaed a xi-fi extreme gamer and having problems getting drivers to insta

    Just bought an extreme gamer and tried to install under win xp pro. I can get the system to recognize the card but when I either try and apply the drivers from the disk or updated drivers from the web the systems then reboots into and endless loop or safe mode? Any ideas? Other than the drivers are bad? ? I have physically re-installing the card. AMD Athlon 64 3400+.5 gig ramNvidia 7600Gt

    Go into the motherboard BIOS and turn off things you do not use, like serial and parallel ports.Free up IRQsTry changing the Plug and Play setting, if currently "Yes" switch to "no".Did you turn off the motherboards built in Sound?Or were you using some other?add on?sound card?

  • G4 Ti4600 VT2D8X - Locked games and other Problems

    HELP!
    I have been having problems with games locking up.
    I looked at the MSI info in display properties and the card was checked at 4x, even though my bios setting of AGP compatability 3.0 is listed as 8X.  It wouldn't let me check the 8X box.
    So I downloaded the latest generic Nvidia driver (ver 44.03), and unfortunately, this cuased more problems.
    Now I can't view the MSI info or MSI clock in display properties. I keep getting an XP error that says, "Run a DLL as an App has encountered a problem and needs to close"
    Now mo matter how many times I uninstall the xp drivers and put the old one back in, I keep getting this error message trying to view MSI info in display properties.
    When my games lock, threre isn't any sound loops happening, but the game freezes visually. I don't think I have a sound card conflict but here are my resources for you to take a look.
    (ISA) 0 System Timer
    (ISA) 1 Standard Keyboard
    (ISA) 3 COM2
    (ISA) 4 COM1
    (ISA) 6 Standard Floppy Disk Controller
    (ISA) 8 System CMOS/real time clock
    (ISA) 12 PS/2 Compatible Mouse
    (ISA) 13 Numeric Data Processor
    (ISA) 14 Primary IDE Channel
    (ISA) 15 Secondary IDE Channel
    (ISA) 20 MS ACPI-Compliant System
    (PCI) 11 Raid Controller (and has a question mark by it)
    (PCI) 16 MSI G4 Ti 4600 with 8X
    (PCI) 17 Creative SB Audigy
    (PCI) 17 OHCI Compliant IEEE 1394 Host Controller
    (PCI) 18 OHCI Compliant IEEE 1394 Host Controller
    (PCI) 19 SIS 900-Based PCI Fast Ethernet Adapter
    (PCI) 20 SIS 7001 PCI to USB Open Host Controller
    (PCI) 21 SIS 7001 PCI to USB Open Host Controller
    (PCI) 22 SIS 7001 PCI to USB Open Host Controller
    (PCI) 23 SIS PCI to USB Enhanced Host Controller
    Should I be concerned about the sound card sharing an irq with the host controller on IRQ 17?
    Also here is my system:
    Asus P4S8X MB
    Intel P4 2.8 Ghz processor
    you know the video card
    CL SB Audigy 2 sound card
    2 sticks of 512k PC2700 DDR ram
    OS: XP
    Also for the fun of it, I used Live update, only to notice that it detected a new driver for me to download for the Ti4800 card. Why does it not recognize my card?
    Someone please help.
    - Mark

    Richard and gfilitti,
    Thank you very much for your continued help. This really means a lot to me.
    Richard I do not use an antivirus program or a firewall program in the background for that matter.
    The only other thing in my sys tray besides nview is a creative console. could that be locking things up?
    gfilitti,
    I acutally dsabled that firewire right after I listed my irq's to test that out. It's still disabled and doesn't seem to help the problem.
    Is it a necessity that I disable system restore before using drivercleaner?  If so I will do it, but would like to think the program would work as normal without doing that.  Also not exactly certain where to disable the system restore.
    So by having 10-second lock up issues, is it safe to say that I don't have any hardware conflicts or potential ram conflicts? There are no irq's being shared and I don't want to pull memory chips if you already know that's not the problem.  I think I am getting close to ending this nightmare. Please help.
    Thank you!!!!!!!!
    - Mark

  • Screeching sounds in games and other problems with Soundblaster live extern

    Okay i have the USB external Creative soundblaster li've sound card. i have had a few problems. My first problem is When im in games such as Americas Army i get random Screeches like a tin can being scraped on concrete. My 2nd problem is Talking with my mic. For others to hear me MONITORING has to be enabled, there for i hear myself out of my own speakers as well. I have done everything to try and fix this, i've tried updating drivers, rolling back drivers, using windows automatic drivers. Is there an option i dont see that is causing my card to not sound good? I am using a 2.0 speaker configuration, and i only play the games with headphones on.
    please help.
    thanks for your time.Message Edited by Zombeh on 0-6-2006 08:30 AM

    You waited 24 hours and gave up? So I'll offer this for anybody else who reads the thread. I have a USB external SB card, but it's in a box somewhere. But IIRC, the Volume Controls work similar to other SB cards. In Volume Controls, Playback, mute the Microphone. In Volume Controls, Recording, select Microphone. This should let you "record" without hearing it on your speakers. Now if a game sets the mixer options for itself, that complicates things. If allowed, choose game audio options similar to these Volume Controls.

  • New to this iPOD game, and having problems! Please help!

    So I finally got my hands on a Nano yesterday, and ever since then some odd things have been happening. I would appreciate any help to the following questions/problems I've been having, because the applecare stuff does not seem to really be either helping or addressing my issues.
    1. When starting iTunes, I was told (once it reconized my nano) that I neeed to install the new software for the nano, i expected this and downloaded it, and followed the directions. As soon as I did that though I started getting "Corrupted Error" messages in iTunes. To get this to stop I just reinstalled iTunes...I was able to transfer things now, but now the system does not seem to reconize that the nano has the new software, and asks if I want to install it, and when I do...(again) I start getting those corrupt errors again.
    2. I will move some songs from my iTunes library, to my nano, and it says they transfer over. I then eject my nano from iTunes, wait for the "do not disconnect" to go away, and unplug it, and sometimes, my newly transfered songs are no longer on my nano. Am I doing something wrong?
    3. I went to update my iPod with some playlists from my library, I went to the options, and said "only update from these lists" It updated my ipod...and deleted everything else off of it, and to add insult to injury, it only added the title of the play list, and NOT the actual song files
    I know this is a lot, but I'm really frustrated, so any help would be appreciated.
    Thank you so much for your time.

    Hi,
    Read this link if it happens again: iPod: What to do if Windows displays an "itunes.exe - Corrupt File" message
    There is another post I think it is in the User Tips Library that goes into more detail as well.
    Regards
    Colin R.

  • Pogo games and Dashboard problems?

    Hi everyone.  I am having a problem ever since downloading Mountain Lion.  While playing Crossword Cove on Pogo I will switch to Dashboard dictionary and enter a word for it's definition, when I finally decide what the answer could be I am not able to type into the crossword box.  What am I doing wrong and how can I fix this?  Any help would be appreciated.  Thanks.

    Try looking up your words using Spotlight and see if that works any better. It shows you the files with those words, but also runs them against the built-in dictionary.
    Make sure you click in the entry box to get an insertion-point before you start typing. The first click just makes that window active -- the second click should give you the insertion-point.

  • Firmware update on my Nokia E52 only run java game...

    Hi, I made that day Firmware update on my Nokia E52 and then update-s all right, only run java games and their sound is gone whether he shall be ON. Anybody have a similar problem and a solution for it?? Firmware-v 052.003 but the date is Cot. 29, 2010) will be happy if you give me an idea how to fix it! I tried quite moratoria preinstall, reset backup I have not done, unfortunately the old Firmware.

    Okay, you are using a MacBook so I am not sure how much help I can give since I use a PC with Vista. In the latest version of Ovi Suite, once the update file has been downloaded and the installation starts, the computer will give your prompts that the phone is disconnected via USB, the phone restarts, the screen flashes, etc. I just leave it alone and after the progress bar on the Ovi Suite ends my phone is updated. I currently have v40. The free maps is available only to v31 and above for 5800 if I remember correctly.
    If possible please use the Ovi Suite instead of PC suite (at least in my experience it works better), and do not in any way touch your phone during updates, even if it "disconnects" from the computer.
    However regarding to your query as to why it is not available via the *#0000# method (or FOTA), updates are generally released through NSU before FOTA, sometimes with as much as a month in difference because the files in FOTA are not the entire update file but rather extractions from it. For example, the v40 FOTA is 17mb (according to someone who said he had it already), while the v40 I downloaded through Ovi Suite was 128mb. 
    If you find my post helpful please click the green star on the left under the avatar. Thanks.

  • Rank in a java game

    Hi ppl,
    I'm newbie in this forum, I'm development a java game and now I would like to implements a rank for players.
    Basically, I have some players that play to the game and then (at game finish) game will write a .txt file with date, score and name player.
    How I can implements it?
    Thanks, regards.
    Michael.

    MichaelStu wrote:
    link is broken...The link works for me, but if for some reason it doesn't work for you, just google "java file IO". Read through the tutorial carefully. Ask a question when you get stuck, and make sure you post an [SSCCE |http://sscce.org] demonstrating the problem.
    then need help in how implements...such as write in a txt file and then apply a bubble sort algorithm?What? You are thinking about it all wrong. Why would you write to a file and then sort?
    One thing at a time. Split your problem up into smaller pieces. Sorting your data is a completely different issue than writing to a file, and for that I'd recommend googling comparators and looking up the sort functions of the Collections and Arrays classes in the API (since links don't work for you, go ahead and google those too).

  • The ever so savvy "creating a java game" post

    Hey, I'm creating a java game, and I did research, and found that this question has been asked many, many times. But my question unfortunately did not match up with any of these posts :( So here goes...
    Im creating a java game, which will run as....kind of a mix between a 2d game, and 3d game (no i am not insane). I dont want the original zelda look, and i dont want the first person shooter look, I want my character to be viewed from an angle, like tibia - if anyone has ever played that. And I also want to leave open the door to changing the view within the game. I figured I can just get my graphics friends to draw things in 3-d, (draw a house [draw the 4 sides and the roof]), and then somehow skew these images to accomodate for a different view.
    I am more than willing to code some kind of graphics engine if what I need is not available, I have looked at a couple and found no such luck.
    So what is the most efficient way to create this game? By just sortof getting all the graphics to be from a certain percpective, and then somehow modifying them with java.....
    or by using some kind of graphics engine that allows me to change views? If so any recomendations?
    Thanks a lot - wow this was long, oh yea a couple Dukes for this too thanks again
    -Mark

    you don't need to do any skewing. Here's what I'd do. I'd store all the tile information in a matrix (Object[][]) with a custom tile class that has the information it needs to retrieve its appropriate image, and certain game related data like slow down factor when a person walks over a certain type of tile, and whether it can be collided with. I'd draw them based on however you decide to angle your tiles. But the important part is you go in this order:
    [0, 0], [0, 1], [1, 0], [0, 2], [1, 1], [2, 0], etc., etc....
    The idea is if you're turning the floor 45 degrees clockwise, to give the correct illusion of depth, you'll want to draw the furthest back tile first, and the furthest tile forward last. Whether you start on the left or right depends on what angle you decide to work with. At a 45 degree angle, it obviously doesn't matter whether you start on the left or right. But if you guess wrong with your rendering, it will show because tiles that are closer to the "camera" will be overlapped by tiles further from the "camera".
    for (int i = 0; i < tiles.length; i++) {
         for (int j = 0; j < tiles.length; j++) {
              graphics2D.drawImage(tiles[i].getImage(), i*horizontalSpacing - camera.getX(), j*verticalSpacing, camera.getY(), null);
    }horizontalSpacing and verticalSpacing will be determined by the angle of your tiles. Set those to match however you make your art.
    Drawing moving sprites will be a bit trickier because you'll have to decide which set of axes to follow... meaning, do you follow the axes of the screen, or the axes of your "rotated world." Give that some thought and once you understand what's happening with the perspective here you'll be able to see which is easiest.
    So there's your engine ;)
    Now, as for the art itself, make them in png format, so that you can have the base of your images be diamond shape, but of course tiles for players and walls and stuff will extend above that diamond. Just don't let them get below the base of their diamond otherwise the tile that gets drawn below them will cut them off. And you don't want a character's feet cut off by the "floor" as he runs ;)
    For your final question, don't let java skew the sprite. The only possible way to make it decent is if when you pick an angle, a 3D render takes your 3D world and it's 3D models and re-renders them at that angle; skewing is simply not capable of creating that illusion. The closest you could get is to simply squish the hight of your art to give the illusion that the camera is moving up, but since you can't expose things higher, like the top of your character's head (since the data doesn't exist in the "lower" version), it will be obviously funny looking.
    Hope that answers your questions, and good luck! I would definitely like to see what you come up with.

  • Java game porting

    Hi,
    I am looking for the guidance to develope Java game porting application

    I would like to know the technical pat as well as process to port Java game to mobile devices. E.g. there is a java game and we have to port it with differetnt languges and different mobile devices.

  • Whenever I use something which uses Java (for example, an online game) and then click the address bar, it seems that the address bar is disabled.

    Whenever I use something which uses Java (for example, an online game) and then click the address bar, it seems that the address bar is disabled. I cannot highlight or type in the address bar unless I interact with another program and then switch back to Firefox. When I interact with Java again, the same problem persists! Help!
    Sorry, I didn't know what category this should be under, but it's urgent.

    Perform the suggestions mentioned in the following articles:
    * [https://support.mozilla.com/en-US/kb/Template:clearCookiesCache/ Clear Cookies & Cache]
    * [[Troubleshooting extensions and themes]]
    Check and tell if its working.
    Some of your Firefox Plugins are out-dated
    * Update All your Firefox Plugins -> [https://www.mozilla.org/en-US/plugincheck/]
    * '''When Downloading Plugins Update setup files, Remove Checkmark from Downloading other Optional Softwares with your Plugins (e.g. Toolbars, McAfee, Google Chrome, etc.)'''

  • Game and Ball Hit problem

    Hello everyone, I am working on a game and was wondering if I could get some help. I have a ball that bounces around in a box, and place one small ball in the applet. I want to create an effect that when the ball that is moving comes into connect with the static ball, the moving ball bounces in the opposite direction. I used this:
    if(x_pos - 100 < 2 & y_pos - 100 < 2 || 100-x_pos < 2 && 100 - y_pos < 2)
    where x_pos and y_pos are for the moving ball, and 100 is the radius of the static ball. Should I use the Pythagoras theorem to do it?
    Thank You In Advance for any help.

    Use java.awt.Shape and its contains() method. It's a standard collision detection idiom.

  • JSP and Java Beans with Database Problem

    hellow, this is my first posting and i hope to help me as fast as you can...
    my problem is simplly i cant get any data from the database (whatever the database it is, i test it with MS Access and MySQL server) when i use a bean, But if i put my connection statement in the JSP file thair is no problem... ???? !!!!
    for example i have a class "Authentication" that have a method to test if the username and password is correct or not and return 1 if true, 0 if false, -1 if thair are some problem in connecting DB.
    now if i create a normal java application that uses this method, it's work and no problems, BUT if i used a JSP page to use this method it's return allways -1

    T1 class:
    package VX;
    import java.sql.*;
    import java.util.*;
    import javax.swing.*;
    public class T1
    //public MBJDBConnection(String driver,String url)
    public T1()
    JDBC_DRIVER = "com.mysql.jdbc.Driver";//driver;
    DATABASE_URL = "jdbc:mysql://localhost:3306/rawafed?user=root;password=0000";//url;
    //=======DB CONNECTION===========================================
    private static String JDBC_DRIVER;
    private static String DATABASE_URL;
    protected Connection connection;
    protected Statement statement;
    //===========End DBC==============================================
    public int update(String sqlUpdate)
         int i=0;
              //connectDB();
              try{
                   i=statement.executeUpdate(""+sqlUpdate);
                   catch(Exception e)
                        System.out.println("Error Inserting Statement Or Connection Not Opened");
              //disconnectDB();
         return i;
    public ResultSet select(String sqlQuery)
              //connectDB();
              ResultSet rs;
              try
              {//open try
              rs=statement.executeQuery(""+sqlQuery);
                   return rs;
              }//end try
              catch(Exception e2)
                   //System.out.println("Error Selecting Statement Or Connection Not Opened");
              }//end catch
              //add to array list
         //return resultList;
         return null;
    //------Methods-------
    public void connectDB()
    //===========================Connection===================
    try
    Class.forName(JDBC_DRIVER);
    catch(Exception e)
    System.out.println("Error : FOR NAME");
    try
    connection = DriverManager.getConnection(DATABASE_URL, "root", "0000");
    catch(Exception e)
    System.out.println("Error : DB URL");
    try
    statement = connection.createStatement();
    catch(Exception e)
    System.out.println("Error : CREATE STATEMENT ERROR");
    public void disconnectDB()
    try
    statement.close();
    connection.close();
    catch(Exception e2)
    System.out.println("Error : CAN'T CLOSE DB");
    T2 Class
    package VX;
    // class Person.
    //Required Class : EDC.EDCDB
    import java.sql.*;
    public class T2
         public T2()
              //initialization
         //........................ Attributes .........................
         private String user;
         private String password;
         private T1 db=new T1();
         private ResultSet rs;
         //......................... Methods .........................
         public String getAdmin(String u,String p)// 0: Failure, 1:Success and he is Administrator, 2: success and he is a regular employee 3: SUCCESS AND HE IS agent
              try
              user=u;
              password=p;
              rs=db.select("SELECT emp_id,password FROM Employee WHERE emp_id="+user+" AND password="+password+" AND Rank_ID=1");
              if(rs.next())
                   return ""+1;
              else
                   rs=db.select("SELECT emp_id,password FROM Employee WHERE emp_id="+user+" AND password="+password+" AND Rank_ID=2");
                   if(rs.next())
                        return ""+2;
                   else
                        rs=db.select("SELECT emp_id,password FROM Employee WHERE emp_id="+user+" AND password="+password+" AND Rank_ID=3");
                        if(rs.next())
                             return ""+3;
                        else return ""+0;
              catch(Exception e){System.out.println("Error \n"+e.getMessage());return ""+e.getMessage()+"\n"+(-1);}
         public int getCard(String u,String p)// 0: Failure, 1:Success and he is Administrator, 2: success
              user=u;
              password=p;
              try
              db.connectDB();
              rs=db.select("SELECT Card_ID,password FROM Card WHERE Card_ID='"+user+"' AND password='"+password+"'");
              if(rs.next())
                   return 1;
              return 0;
              catch(Exception w)
                   return -1;
              finally
                   //System.out.println("Done");
                   db.disconnectDB();
         public int getAny()
              return 1;
    }//end class
    This is a tested class and it's work OK
    import VX.T2;
    public class T3
         public static void main(String [] args)
              System.out.println("System Started...");
              try
                   T2 t2=new T2();
                   System.out.println(t2.getCard("1","a"));
              catch(Exception e)
                   System.out.println("Opsssss ...");
    Now this is the JSP Code that OK and Run without any problems
    <%@ page contentType="text/html; charset=windows-1256" language="java" import="java.sql.*" errorPage="" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1256" />
    <title>test</title>
    </head>
    <body>
    <%
    //Mazin B. Jabarin 20210464
    //Testing JSP - MySQL Server Driver
    String connectionURL = "jdbc:mysql://localhost:3306/EDCDB?user=root;password=0000";
    Connection connection = null;
    Statement statement = null;
    ResultSet rs = null;
    %>
    <%
    try{
    Class.forName("com.mysql.jdbc.Driver");
    connection = DriverManager.getConnection(connectionURL, "root", "0000");
    statement = connection.createStatement();
    rs = statement.executeQuery("SELECT * FROM a");
    while (rs.next()) {
    out.println(rs.getString("id")+"<br>");
    rs.close();
    catch(Exception e)
    out.print("Error : "+e.getMessage());
    %>
    </body>
    </html>
    Now this JSP File always returns (-1) ???? !!!!!!!
    <%@ page contentType="text/html; charset=iso-8859-1" language="java" import="java.sql.*" import="VX.T2" import="java.util.*" errorPage="" %>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head>
    <body>
    <%
    try
    T2 t2=new T2();
    out.println("Result Still : "+t2.getCard("1","a"));
    catch(Exception w)
    out.println("<BR> Error In Execution ??? "+w.getMessage());
    %>
    </body>
    </html>
    ++++++++++++++++++++++++++++
    any one can help me please :(
    i use tomcat as web-application
    and i install jdk 1.5
    also JBulder 7
    (now i supposed that the JBulder make some conflict, so i uninstalled it but still Not Working) ...
    before one year i was working just like this way and it was working
    but now i dont know what is the problem
    i am really need help.

  • Problem with Java 5 and Oracle 10g JDBC driver

    Hi All,
    Currently we upgrade our web application to Java 5 and Oracle 10.2 JDBC driver. And we encountered a bug, when the user entered the information through UI and data didn't store into database (Oracle 9i). The problem is that this bug is not happend so often maybe once a day and this did not happen before we upgraded to Java 5 and Oracle 10.2 JDBC driver. Does anyone encounter the same problem ? Is this Java 5 problem or Oracle JDBC driver problem ?
    Thanks,

    sounds like a database problem...
    Are you using a driver version that's supported for your database engine?
    What else did you change? We once ran into a major bug in our application that had for 5 years been masked by performance problems in our hardware and infrastructure.
    Once those were resolved the bug showed itself and caused tens of thousands of records to be erroneously inserted into our database every day.
    It's certainly NOT a problem with your JVM (if it's a decent one, like the Sun implementation).
    So it's either your database, your driver, your network (dropping packets???), or your application.
    The upgrade may just have exposed something that was already there.

Maybe you are looking for

  • Phone not working after update today

    >>Duplicate post removed to comply with the Verizon Wireless Terms of Service.  See Applied OTA update and now phone doesn't work!<< Message was edited by: Verizon Moderator

  • Image as a column link in a report

    Hi folks, I want my thumbnail to be the link in my report. I have set my "Link text" as #THUMBNAIL#. In the help for the "link text" it says "Enter the HTML text to be shown as a link. Use an image tag to display images, or pick from the list of defa

  • Custom counter not labeling clips in correct sequence

    Anyone know why my custom counter feature is no longer assigning numbers to my clips in the right order?  I have a series of clips -- say an interview -- I select them all in sequence, and then using custom name and counter I expect to see them numbe

  • Powl in webdynpro abap

    hi, in My trip and expense on all my expense report tab depends upon status i need to add link othrewise disable the link powl class cl_fitv_powl_feeder class please help regards, kanchan

  • Please answer me quickly .........

    Will Siri support iPad 2 in iOS 6 Please experts answer me , but a sure answer please.