How to use the scanner class to ask for a character?

Hey guys, this is my assignment:
Ask the user for a single letter and a sentence, and print out the
number of times that letter shows up in the sentence.
Please tell me how to scan for a character. I tried this:
import java.util.Scanner;
public class Frequencies
    public static final void main(String[] args)
        Scanner scanner = new Scanner(System.in);
        Scanner scan = new Scanner(System.in);
        System.out.println("Enter a sentence");
        String x = scanner.next();
        System.out.println("Enter a letter to look for");
        String y = scan.next();
        char z = y.charAt(0);
        int chara = 0;
        for(int i = 0; i<x.length(); i++){
                if(z==y.charAt(i)){
                        chara = chara++;
        System.out.println("There are " + chara + " " + z + "s in the sentence");
}and got the error after Running (not compiling):
Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range: 1
        at java.lang.String.charAt(String.java:687)
        at Frequencies.main(Frequencies.java:16)I thought this meant that I was asking for the character in postition 1 of string y, but in my code I wrote position 0
when I tried inserting words in the character place (just to see what happened, not expecting functionallity, I got
Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range: [NUMBER OF CHARACTERS]
        at java.lang.String.charAt(String.java:687)
        at Frequencies.main(Frequencies.java:16)Please help.
The assignment isn't due nor graded, this is just killing me lol.
Thanks in advance
Edited by: Sevan on Oct 18, 2008 4:40 PM

jverd wrote:
Skydev2u wrote:
I've used this method for a while now and it gets the job done.
import java.util.Scanner;
public class ReadInput {
public static void main(String[] args) {
Scanner UserInput = new Scanner(System.in);
char letter = UserInput.findWithinHorizon(".", 0).charAt(0);
I know you're trying to help, but this isn't really doing it. It does nothing to address the source of the OP's problem. The way he's doing it now is almost right. He just needs to do a tiny bit of detective work to fix a small bug. Tossing off a totally different approach, with no explanation, is not particularly helpful.Your right jverd I skimmed the OP's problem too quick;y and in tern didn't understand it fully. After reading the post thoroughly I saw that the problem can be solved by taking the sentence the user enters and then converting it into a array of characters. Then searching for the specific letter the user enters is achieved by comparing it to each individual element of the char array. Then incrementing a counter variable each time a match is made. I hope this example code solve your problem.
* @author skydev
import java.util.Scanner;
public class SentenceReader {
    public static void main(String[] args) {
        int counter = 0; //Amount of time the letter appears in the sentence
        char letter;    //Letter the user search for
        char[] sentenceArray; //char array to hold the elements of the string the user inputs
        String sentence; //sentence the user inputs
        Scanner UserInput = new Scanner(System.in);
        System.out.println("Please enter a sentence! ");
        sentence = UserInput.nextLine();
        sentenceArray = sentence.toCharArray(); //splits up the users sentence into a array of char
        System.out.println("Please enter a letter to search for ");
        letter = UserInput.findWithinHorizon(".", 0).charAt(0);
         for(int i = 0; i < sentence.length(); i++){
                if(letter == sentenceArray){ //search to see if the letter of interest equals to each char (letter) of the array
counter++; //increments the amount of time the letter appears, set to 0 by default
System.out.println("The letter appeared " + counter + " times in the sentence"); //Displays the result :) I love programming

Similar Messages

  • How to use the different class for each screen as well as function.

    Hi Experts,
    How to use the different class for each screen as well as function.
    With BestRegards,
    M.Thippa Reddy.

    Hi ThippaReddy,
    see this sample code
    Public Class ClsMenInBlack
    #Region "Declarations"
        'Class objects
        'UI and Di objects
        Dim objForm As SAPbouiCOM.Form
        'Variables
        Dim strQuery As String
    #End Region
    #Region "Methods"
        Private Function GeRate() As Double
                Return Double
        End Function
    #End Region
    Public Sub SBO_Appln_MenuEvent(ByRef pVal As SAPbouiCOM.MenuEvent, ByRef BubbleEvent As Boolean)
            If pVal.BeforeAction = True Then
                If pVal.MenuUID = "ENV_Menu_MIB" Then
                End If
            Else ' Before Action False
                End If
        End Sub
    #End Region
    End Class
    End Class
    Rgds
    Micheal
    Vasu Anna Regional Feeling a???? Just Kidding
    Edited by: micheal willis on Jul 27, 2009 5:49 PM
    Edited by: micheal willis on Jul 27, 2009 5:50 PM

  • How to use the implementation class in propetty pallete

    Hi,
    I am using forms 10g....I have to insert horizontal scroll bar in text item..
    I have only class files instead of jar files ...how cani place the class file instead of jar file...
    How to use the implementation class in property palette to display the PJC
    Thanks,
    Ansaf.

    The Implementation Class must reflect the full name of the class. For instance, if the full class name is : xx.yyy.zz.class_name, then put this in the Implementation Class property of the corresponding item.
    Also, the class must be stored in the equivalent directory structure, so that, in my example: <DEV_HOME>/forms/java/xx/yyy/zz
    Francois

  • How to use the Rectangle class to draw an image and center it in a JPanel

    I sent an earlier post on how to center an image in a JPanel using the Rectangle class. I was asked to send an executable code which will show the malfunction. The code below is an executable code and a small part of a very big project. To simplifiy things, it is just a JFrame and a JPanel with an open dialog. Once executed the JFrame and the FileDialog will open. You can then navigate to a .gif or a .jpg picture and open it. What I want is for the picture to be centered in the middle of the JPanel and not the upper left corner. It is also important to stress that, I am usinig the Rectangle class to draw the Image. The region of interest is where the rectangle is created. In the constructor of the CenterRect class, I initialize the Rectangle class. Then I use paintComponent in the CenterRect class to draw the Image. The other classes are just support classes. The MyImage class is an extended image class which also has a draw() method. Any assistance in getting the Rectangle to show at the center of the JPanel without affecting the size and shape of the image will be greatly appreciated.
    I have divided the code into three parts. They are all supposed to be on one file in order to execute.
    import java.awt.*;
    import java.awt.image.*;
    import javax.swing.*;
    public class CenterRect extends JPanel {
        public static Rectangle srcRect;
        Insets insets = null;
        Image image;
        MyImage imp;
        private double magnification;
        private int dstWidth, dstHeight;
        public CenterRect(MyImage imp){
            insets = getInsets();
            this.imp = imp;
            int width = imp.getWidth();
            int height = imp.getHeight();
            ImagePanel.init();
            srcRect = new Rectangle(0,0, width, height);
            srcRect.setLocation(0,0);
            setDrawingSize(width, height);
            magnification = 1.0;
        public void setDrawingSize(int width, int height) {
            dstWidth = width;
            dstHeight = height;
            setSize(dstWidth, dstHeight);
        public void paintComponent(Graphics g) {
            Image img = imp.getImage();
         try {
                if (img!=null)
                    g.drawImage(img,0,0, (int)(srcRect.width*magnification), (int)(srcRect.height*magnification),
              srcRect.x, srcRect.y, srcRect.x+srcRect.width, srcRect.y+srcRect.height, null);
            catch(OutOfMemoryError e) {e.printStackTrace();}
        public static void main(String args[]) {
            java.awt.EventQueue.invokeLater(new Runnable() {
                public void run() {
                    new Opener().openImage();
    class Opener{
        private String dir;
        private String name;
        private static String defaultDirectory;
        JFrame parent;
        public Opener() {
            initComponents();
         public void initComponents(){
            parent = new JFrame();
            parent.setContentPane(ImagePanel.panel);
            parent.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
            parent.setExtendedState(JFrame.MAXIMIZED_BOTH);
            parent.setVisible(true);
        public void openDialog(String title, String path){
            if (path==null || path.equals("")) {
                FileDialog fd = new FileDialog(parent, title);
                defaultDirectory = "dir.image";
                if (defaultDirectory!=null)
                    fd.setDirectory(defaultDirectory);
                fd.setVisible(true);
                name = fd.getFile();
                if (name!=null) {
                    dir = fd.getDirectory();
                    defaultDirectory = dir;
                fd.dispose();
                if (parent==null)
                    return;
            } else {
                int i = path.lastIndexOf('/');
                if (i==-1)
                    i = path.lastIndexOf('\\');
                if (i>0) {
                    dir = path.substring(0, i+1);
                    name = path.substring(i+1);
                } else {
                    dir = "";
                    name = path;
        public MyImage openImage(String directory, String name) {
            MyImage imp = openJpegOrGif(dir, name);
            return imp;
        public void openImage() {
            openDialog("Open...", "");
            String directory = dir;
            String name = this.name;
            if (name==null)
                return;
            MyImage imp = openImage(directory, name);
            if (imp!=null) imp.show();
        MyImage openJpegOrGif(String dir, String name) {
                MyImage imp = null;
                Image img = Toolkit.getDefaultToolkit().getImage(dir+name);
                if (img!=null) {
                    imp = new MyImage(name, img);
                    FileInfo fi = new FileInfo();
                    fi.fileFormat = fi.GIF_OR_JPG;
                    fi.fileName = name;
                    fi.directory = dir;
                    imp.setFileInfo(fi);
                return imp;
    }

    This is the second part. It is a continuation of the first part. They are all supposed to be on one file.
    class MyImage implements ImageObserver{
        private int imageUpdateY, imageUpdateW,width,height;
        private boolean imageLoaded;
        private static int currentID = -1;
        private int ID;
        private static Component comp;
        protected ImageProcessor ip;
        private String title;
        protected Image img;
        private static int xbase = -1;
        private static int ybase,xloc,yloc;
        private static int count = 0;
        private static final int XINC = 8;
        private static final int YINC = 12;
        private int originalScale = 1;
        private FileInfo fileInfo;
        ImagePanel win;
        /** Constructs an ImagePlus from an AWT Image. The first argument
         * will be used as the title of the window that displays the image. */
        public MyImage(String title, Image img) {
            this.title = title;
             ID = --currentID;
            if (img!=null)
                setImage(img);
        public boolean imageUpdate(Image img, int flags, int x, int y, int w, int h) {
             imageUpdateY = y;
             imageUpdateW = w;
             imageLoaded = (flags & (ALLBITS|FRAMEBITS|ABORT)) != 0;
         return !imageLoaded;
        public int getWidth() {
             return width;
        public int getHeight() {
             return height;
        /** Replaces the ImageProcessor, if any, with the one specified.
         * Set 'title' to null to leave the image title unchanged. */
        public void setProcessor(String title, ImageProcessor ip) {
            if (title!=null) this.title = title;
            this.ip = ip;
            img = ip.createImage();
            boolean newSize = width!=ip.getWidth() || height!=ip.getHeight();
         width = ip.getWidth();
         height = ip.getHeight();
         if (win!=null && newSize) {
                win = new ImagePanel(this);
        public void draw(){
            CenterRect ic = null;
            win = new ImagePanel(this);
            if (win!=null){
                win.addIC(this);
                win.getCanvas().repaint();
                ic = win .getCanvas();
                win.panel.add(ic);
                int width = win.imp.getWidth();
                int height = win.imp.getHeight();
                Point ijLoc = new Point(10,32);
                if (xbase==-1) {
                    xbase = 5;
                    ybase = ijLoc.y;
                    xloc = xbase;
                    yloc = ybase;
                if ((xloc+width)>ijLoc.x && yloc<(ybase+20))
                    yloc = ybase+20;
                    int x = xloc;
                    int y = yloc;
                    xloc += XINC;
                    yloc += YINC;
                    Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
                    count++;
                    if (count%6==0) {
                        xloc = xbase;
                        yloc = ybase;
                    int scale = 1;
                    while (xbase+XINC*4+width/scale>screen.width || ybase+YINC*4+height/scale>screen.height)
                        if (scale>1) {
                   originalScale = scale;
                   ic.setDrawingSize(width/scale, height/scale);
        /** Returns the current AWT image. */
        public Image getImage() {
            if (img==null && ip!=null)
                img = ip.createImage();
            return img;
        /** Replaces the AWT image, if any, with the one specified. */
        public void setImage(Image img) {
            waitForImage(img);
            this.img = img;
            JPanel panel = ImagePanel.panel;
            width = img.getWidth(panel);
            height = img.getHeight(panel);
            ip = null;
        /** Opens a window to display this image and clears the status bar. */
        public void show() {
            show("");
        /** Opens a window to display this image and displays
         * 'statusMessage' in the status bar. */
        public void show(String statusMessage) {
            if (img==null && ip!=null){
                img = ip.createImage();
            if ((img!=null) && (width>=0) && (height>=0)) {
                win = new ImagePanel(this);
                draw();
        private void waitForImage(Image img) {
        if (comp==null) {
            comp = ImagePanel.panel;
            if (comp==null)
                comp = new JPanel();
        imageLoaded = false;
        if (!comp.prepareImage(img, this)) {
            double progress;
            while (!imageLoaded) {
                if (imageUpdateW>1) {
                    progress = (double)imageUpdateY/imageUpdateW;
                    if (!(progress<1.0)) {
                        progress = 1.0 - (progress-1.0);
                        if (progress<0.0) progress = 0.9;
    public void setFileInfo(FileInfo fi) {
        fi.pixels = null;
        fileInfo = fi;
    }

  • How to use the message class CL_BSP_MESSAGES in the event handler?

    Hiii,
    I need to use the message class CL_BSP_MESSAGES in the even handler, because I need to use the Condition co_cancel_event_prefix to prevent saving in the method
    global_messages->add_message(
                                            condition = co_cancel_event_prefix
                                            message   = TEXT-010
                                            severity  = cl_bsp_messages=>co_severity_error ).
                                            dummy     = ME->COMPONENT_ID ).
    Can anybody explain me how to use this method?
    Kind Regards,
    John

    solved

  • Anyone use the scanner class?

    The scanner class makes command line input easy:
    Scanner input = new Scanner(System.in);
    input.nextLine() returns the string
    My result always appears before the input is shown. For example:
    Please enter a string: You entered this is a string
    this is a string<--the user input isn't displayed after the prompt.
    How do I make the user input appear right after the prompt? Thank you.

    ShaqDiesel wrote:
    The scanner class makes command line input easy:
    Scanner input = new Scanner(System.in);
    input.nextLine() returns the string
    My result always appears before the input is shown. For example:
    Please enter a string: You entered this is a string
    this is a string<--the user input isn't displayed after the prompt.
    How do I make the user input appear right after the prompt? Thank you.What? I don' understand your post. What is expected result, and what do you get?
    Kaj

  • Can anyone help me with this program using the Scanner Class?

    I have to write a program that asks for the speed of a vehicle (in miles-per-hour) and the number of hours it has traveled. It should use a loop to display the distance a vehicle has traveled for each hour of a time period specified by the user. Such as 1 hour will equal 40 miles traveled, 2 hours will equal 80, 3 hours will equal 120, etc. This is what I've come up with thus far. Any help is appreciated.
    import java.util.Scanner;
         public class DistanceTraveled
              public static void main(String[] args)
                   int speed;
                   int hours;
                   int distance;
                   Scanner keyboard = new Scanner(System.in);
                   System.out.print("What is the speed of the vehicle in miles-per-hour?");
                   speed = keyboard.nextInt();
                   System.out.print("How many hours has the vehicle traveled for?");
                   hours = keyboard.nextInt();
                   distance = speed*hours;
                   while (speed < 0)
                   while (hours < 1)
                   System.out.println("Hour     Distance Traveled");
                   System.out.println("------------------------");
                   System.out.println(hours + " " + distance);
    }

    When you post code, wrap it in code tags. Highlight it and click the CODE button above the text input area.
    You seem to be trying to reuse the speed and hours variables in your loop. That's probably a mistake at this point. Keep it simpler by defining a loop variable.
    Also I don't see the need for two loops. You just want to show how far the vehicle has traveled for each one-hour increment, assuming constant speed, for the number of hours it has been traveling, right? So a single for loop should be sufficient.

  • How to use the java class created by  "CONTIVO" as web sevrvice?

    Hi All,
    We are creating the java class by the Contivo mapping tool, how to use that class as a web serivce?
    Very thankful if anyone gives some light on this.
    Thanks in advance.....
    rgds,
    Rajeev Pariyadathu

    com.contivo.runtime.dom.Transform
    Transform.transform(     "Transform_HotelAvailRQ_",file1, file2);, like this we can use the contivo generated class

  • Where can I find out how to use the Journals feature in iPhoto for iPhone

    I am new to Apple Support Communities. Not sure if this is the place that will help me work with Journals. Is there a manual or video which helps with teaching the features of the Journals application and how to use them? I am stuck knowing how to move around the images and changing the page set-up, among other perplexing features.  

    You need the  iPhoto for iOS forum is here
    https://discussions.apple.com/community/app_store/iphoto_for_ios
    Regards
    TD

  • How to use the program "Generate test data for BAI bank statement" ?

    Hi all,
    I use the program RFEBKAT5 to create an Electronic Bank Statement file in BAI format ,but it doesn't generate the file .
    I don't know how to generate the file.
    Please help me !
    Thanks all !

    You need to suitably adjust your GL accounts for "Posting Offset Account" (Whisch is defaulted as ++++++++19" and Checkout/Funds Out/Funds IN GL accounts to your configuration.
    Once you do this try generating the file again.

  • How to use the first row function value for the rest of records

    Hi all,
    I am having a select statement like this. We are calling function enabled for each row. So it is taking
    time. As per our bussiness logic, we can use what the function 'enabled' will give for the first row to
    other rows also. so that we can avoid calling the function 'enabled' next row onwars.
    Before
    SELECT
    decode(enabled(col1, col2, col3),'TRUE','xxx', col4),
    decode(enabled(col1, col2, col3),'TRUE','xxx', col5),
    decode(enabled(col1, col2, col3),'TRUE','xxx', col6),
    decode(enabled(col1, col2, col3),'TRUE','xxx', col7),
    decode(enabled(col1, col2, col3),'TRUE','xxx', col8),
    from
    table1 t1, table2 t2 where t1.col1 = t2.col1
    After
    SELECT
    decode(enabled(col1, col2, col3),'TRUE','xxx', col4),
    decode('true/false','TRUE','xxx', col5), --Here 'true/false' is the first row value after calling the function 'enabled'
    decode('true/false','TRUE','xxx', col6),
    decode('true/false','TRUE','xxx', col7),
    decode('true/false','TRUE','xxx', col8),
    from
    table1 t1, table2 t2 where t1.col1 = t2.col1
    Any thoughts on this, how to implement this logic
    Thanks,
    Pal

    It's not clear where col1, col2, col3... etc. come from, so I've assumed they're in table1.
    with table1_X as (select enabled(col1, col2, col3) as enbl
                            ,col1, col2, col3, col4, col5, col6, col7, col8
                      from   table1)
    SELECT decode(t1.enbl,'TRUE','xxx', col4)
          ,decode(t1.enbl,'TRUE','xxx', col5)
          ,decode(t1.enbl,'TRUE','xxx', col6),
          ,decode(t1.enbl,'TRUE','xxx', col7),
          ,decode(t1.enbl,'TRUE','xxx', col8),
    from   table1_x t1 join table2 t2 on (t1.col1 = t2.col1)p.s. you'd be better leaving out the enabled function altogether and incorporating the logic of the function directly in the SQL, and then you would be avoiding any context switching which will clearly impact performance on any large amount of data.
    Edited by: BluShadow on 14-May-2013 08:26

  • How to use the songs in iPhone 6 for ringtone

    Is it possible to use the songs in the phone for ringtone, how to set?

    I got a iphone 6 yesterday and when I did my back up on iTunes my ring tones would not go back into my device I tried a few times and maybe is one of those bugs right now the iTunes store sell a lot of great music apps

  • Using the new-look forums, asking for positive comments

    Dear Fellow Users,
    I am starting a discussion on how to make the most of this revised website for Apple Support Communities. Please keep this discussion positive. Please confine complaints to one of the many negative threads.
    Remember that many of these changes are the result of feedback to Apple. We may have got what we wished for.
    Gains:
    - Spell checker in the Reply box;
    New ways of working:
    - The blue dot has gone. I can't tell which discussions I have or haven't read.
    Tip by deggie. In the home page of a forum, click to the right of the address bar of your browser, add /content at the end of the URL. Press enter. You will see three options across the page just above the threads: All Content, User Tips and Discussions. Click on Discussions. Threads with new content will have titles that are in bold. Now save that page in your browser bookmarks. For example, my bookmark for the 'Using Apple Support Communities' forum, shows this URL:
    https://discussions.apple.com/community/using_apple_support_communities/content? filterID=contentstatus%5Bpublished%5D~objecttype~objecttype%5Bthread%5D
    And the view is Bold for unread
    - The forums keep logging me off after a period of inactivity.
    Good. That may stop the spammers posting multiple messages that have nothing to do with the purpose of a forum.
    More gains or workarounds, anyone?
    Regards,
    Ian.
    <Link Edited By Host>

    You guys are worse than the complainers we get with iOS or OSX updates (and this is not directed specifically at you PV - you were just the last post). As Yellowbox indicated, there are already a plethora of negative posts about the changes. So, go there and complain.
    People don't like change, OK, I get that. But seriously, when it is foist upon you, ******** and moaning isn't going to put it back the way it was. Why not spend all that energy in trying to figure out the way to make the most out of what you have been given. Not everything about the new site is horrible. Sure there are improvements to be made, but we are supposed to be people with creative minds, interest in challenges, abilities to suss out the more esoteric aspects of things.
    As I indicated in one of my earlier posts, because I have a catholic approach to reading the boards, I am not seeing some of the issues that folks who like to support specific communities are having. But, for my purposes, I find it much easier to move back and forth from current posts, posts that I have responded to, posts that I have authored. When looking at Content>All, I am not having any difficulty seeing what the current posts are, and if I want to see if a post I have been involved with is updated, it is a quick click to the Participated link to see which of those posts have been updated recently, and which I have already responded to after they have been updated.
    I would like to see some enhancements and changes made, and I think that the valid issues that people are having need to be addressed. But I would like to see more tips like the ones deggie has provided coming from all of us. The whining and complaining is just boring....
    Just my 2 cents....
    GB

  • How to use the same mask, stencil, etc., for multiple layers? Photoshop equivalent of masked group?

    Hi I spent more than half an hour to search manual, forums, and Internet and still can't find the answer. Please help!
    For example, in a comp with 5 or more layers I want to use the same mask or stencil or what ever can hide areas of the layers 2,3, and 4 but layer 5 and any other eventual layers below should not be affected.

    Pre-compose the layers you want to mask and apply a track matte to the pre-comp using the mask. Think of pre-composing as an equivalent of creating a layer group.
    Use Set Matte effect on each of the layers you want to mask. This is easiest to do if you apply set matte once and then create an animation preset to apply to the other layers. Just get set matte to do what you want it to do on the first layer, Select Set matte in the ECW or in the Timeline, then go to Animation>Save animation preset. Then select all of the other layers you want to apply the set matte to and apply the preset.
    Put the mask at the bottom of the layers you want to mask and enable the preserve transparency switch, then nest this group in the composition with the other layers.
    Here's another tip. You could define a custom color for all of the layers you want to use the matt on, then use the custom color for a group selection. This may make things easier down the line.

  • How to find the Message Class and ID for messages in WebIC

    Dear Experts,
    I get some error messages in the WebIC
    I went to SAAB to activate and see details on the error messages
    But, what i am missing is the the message class and the ID information
    Can any one tell me if there is a work around to check and find out which message class and ID the message belongs to
    Regards,
    Raj

    Hi Raj,
    Put a break-point in method get_instance or ADD_MESSAGE of class cl_bsp_wd_message_service.
    Best regards,
    Caíque Escaler

Maybe you are looking for

  • Check box in a table field

    Hi experts , I have a requirement of having one of the table field as checkbox .when i kept it as checkbox it is not getting reflected in sm30 .i need to have a check box displayed in the field of the table in sm30 .

  • My hp 6500 all in one will not print from photo gallery

    hav downlaoded digital pics and tried to print from photo gallery with no success.  documents will print from ms word but cannot print pics

  • Enabling 802.11n on the 861-w ISR

    Hello, I'm attempting to configure 11n on the 861W router integrated access point. I've configured speed basic-1.0 2.0 5.5 11.0 6.0 9.0 12.0 18.0 24.0 36.0 48.0 54.0 m0. m1. m2. m3. m4. m8. m9. m10. m11. m12. m13. m14. m15. But still can't connect fa

  • I can't open the "Keepsafe" App after update.

    I can't open the "Keepsafe" App after update it to the latest version, When i click on the app and after 20 second it's quickly goes back to the home screen, I've tried reopening this App and restarting my iphone but still not working. Please Help me

  • JTA is not working for me

    I am useing Spring 2.0 + mysql 5.0 and jbossts for my transaction. I have only one datasourse : In my code: TransactionManager transactionManager = trxManager.getTransactionManager(); transactionManager.begin(); long i = jDBCDBHandler.readValue(); Sy