Gtksql pkgbuild. Simple GUI for sql queries.

This is simple program for running sql queries. I made this pkgbuild some time ago but I'm not sure how much it is good. Gtksql should support both mysql and postgresql but postgresql support is broken (probably to old). Developer promises a brand new gtk2 based application. We will see...
Since I can't make this pkgbuild any better I'm just posting it.
gtksql PKGBUILD
pkgname=gtksql
pkgver=0.4.2
pkgrel=1
pkgdesc="Gtk front-end for sql queries"
url="http://gtksql.sourceforge.net/"
depends=('lua' 'gtk')
makedepends=('mysql')
source=(http://dl.sourceforge.net/sourceforge/gtksql/$pkgname-$pkgver.tar.gz)
md5sums=('a0ba598027cd49f69f951a31342b51fd')
build() {
cd $startdir/src/$pkgname-$pkgver
./configure --prefix=/usr
--with-mysql
--with-lua
make || return 1
make prefix=$startdir/pkg/usr install

Hello:
I'm trying to do add a calculated variable to my view that isn't an Entity
Attribute, its simple really but i don't know if I'm leaving something out or
not.
I add the "new Attribute" , call it nCompleted, type - number
I then check off everything as is required(as documented in Help)
for an Sql Derived Attribute, the following code is entered in the
Expression Box :
Select group_services.office, count(client_group_services.clnt_group_services_id) as nCompleted
Where group_services_id=client_group_services_id(+)
And client_group_services_id.result="Completed";
It isn't working, what am I missing???? Sheena:
It probably isn't working because of missing 'group by' clause. I don't know the exact detail of your query statement, but suppose you want to count number of employees in a dept, then you're query should look like:
select dept.deptno, dept.dname, count(emp.empno) as nCount
   from dept, emp where dept.deptno = emp.deptno(+)
   group by dept.deptno, dept.dname  // This group-by is important
OR if you want to use nested SELECT
select dept.deptno, dept.dname,
   (select count(emp.empno) from emp where dept.deptno=emp.deptno(+)) as nCount
   from dept

Similar Messages

  • Datasource for SQL Queries

    Hi,
    SQL Server best practices indicates the use of Windows Authentication instead of Mixed Mode.
    In this case, if you need to create reports that connect to the database,you need to add the users accessing the data source to the sql server security.
    For reports that show error logs and table contents do you create a specific domain account for SQL queries and then specify it on the data source?
    Thank you

    Hi Pedro,
    A report server uses credentials to connect to external data sources that provide content to reports or recipient information to a data-driven subscription. You can specify credentials that use Windows Authentication, database authentication, no authentication,
    or custom authentication. When sending a connection request over the network, the report server will either impersonate a user account or the unattended execution account. For more information about the security context under which a connection request is
    made, see
    Data Source Configuration and Network Connections further on in this topic.
    The network environment determines the kinds of connections you can support. By default, when you create an datasoource the credential is "Windows Authentication(Windows integrated security)", as you know, the user must has permission to the server
    and database.
    Each user must have a Windows account. It can be a local account (i.e., an account on the report server) or a trusted domain account. The account must be added as an allowed user to the report server either individually or as part of a group. Furthermore,
    the client application must support Windows integrated security.
    More details information please reference to below article:
    Understanding SQL Server Reporting Services Authentication
    Specify Credential and Connection Information for Report Data Sources
    If you still have any problem, please feel free to ask.
    Regards,
    Vicky Liu
    Vicky Liu
    TechNet Community Support

  • Bambus a simple Gui for any Console tool to draw the backgroundimage

    Bambus is a smal and simple Gui(GTK) for any Console tool to draw the backgroundimage like feh, Esetroot, Habak, hsetroot etc.
    To the Aur: http://aur.archlinux.org/packages.php?ID=34424!
    Here is a german Wiki: https://wiki.archlinux.de/title/Hinterg … d_anpassen
    Info:
    Name: Bambus
    Version: 2.2
    Gui: gtkmm
    Licens: GPL3
    Screenshots:
    To start bambus enter
    bambus
    To restore a backgroundimage type
    bambus -restore
    To restore any backgroundimage type
    bambus -any
    And to restore a backgroundimage in an order:
    bambus -each
    To add an extension in the extensionbox add a line in the .bambus.conf
    command_extension=Esetroot -s
    It is only a fun project and i am sorry for my bad english.:P
    Last edited by ying (2010-04-26 17:57:59)

    Tried it, worked as expected. Nice simple interface (maybe add a close button on the info window, well, maybe it's normal like this, i just don't like killing windows from outside(the window manager)).
    Not that i'd use it, i rarely change my background image and if i do i do it via feh or similar on cli directly.
    Btw, i modified the PKGBUILD a little, maybe you like the changes:
    # Bambus
    # Maintainer: Malisch Technology Solutions <http://malisch-ts.de>
    # Contributor: Malisch Technology Solutions <http://malisch-ts.de>
    pkgname=bambus
    pkgver=2.2
    pkgrel=5
    pkgdesc="A small and simple GTK Gui to change Wallpapers using feh, Esetroot, hsetroot, habak or any other command tool."
    url="http://malisch-ts.de"
    arch=('i686' 'x86_64')
    license=('GPL3')
    depends=('gtkmm') # 'eterm' can be changed in any command tool to draw the wallpaper.
    optdepends=('eterm/habak/feh/hsetroot/or others: for setting the background')
    source=(http://malisch-ts.de/Downloads/bambus/bambus-${pkgver}-source.tar.gz)
    md5sums=('7f6388cc6a74b1fe68f9ad6d04064a17')
    build() {
    g++ -o bambus main.cpp `pkg-config --cflags --libs gtkmm-2.4`
    package() {
    install -Dm755 bambus $pkgdir/usr/bin/bambus || return
    Last edited by Ogion (2010-05-14 14:01:56)

  • Ruby code for sql queries

    Hello everybody,
    First off, let me apologize if my inquiry does not belong on this forum. I am confident however, that someone here has had experience with this since Oracle and ruby on rails/ruby are used frequently. My fingers are crossed, here's is my problem:
    I am currently working on a database system that utilizes ruby on rails
    with a oracle database. Here's the situation:
    the ruby on rails web application is up and running;
    my oracle database is full of tables that are populated with data;
    there is a successful connection between rails and my oracle database;
    however, what isn't finished is I currently have data mining queries in
    sql (eg. find minimum time someone has been employed = "Select
    min(time) from table...etc") and what I need to do is write one ruby
    program for each of my sql queries so that the ruby program:
    1) connects to the oracle database each time the query is called
    2) runs the sql query on the oracle database
    3) takes the results from the query and returns them in an array or
    something of that nature (so that I can use the results in an html file
    on the ruby on rails web application).
    Again, I apologize if this question does not belong on this forum. If someone however has experience with this could you please give me example code of what this would look like (using different sql queries). Thank you

    I apologize if this question does not belong on this forum. OTN does have a forum dedicated to Ruby/Ruby On Rails. I admit it doesn't seem to get much traffic. I think that's because most people working with Ruby tend to go for F/OSS products.
    Cheers, APC
    Blog : http://radiofreetooting.blogspot.com/

  • Need help for SQL Queries Tunning

    hi all,
    we have a procedure for search consumers, which using sql queries like:
    SELECT TRIM (NAME) AS NAME, TRIM (accno) AS accno,
    TRIM (connaddress) AS connaddress,
    TRIM (CATEGORY) AS CATEGORY, TRIM (landmark) AS landmark,
    SUBSTR (accno, 1, 3) AS subdivisionname
    FROM consumermaster
    WHERE LOWER (accno) LIKE
    LOWER ('%' || NVL (caccno, '#noval#') || '%')
    OR LOWER (NAME) LIKE LOWER ('%' || NVL (cname, '#noval#') || '%')
    OR LOWER (connaddress) LIKE
    LOWER ('%' || NVL (cadd, '#noval#') || '%')
    OR phone LIKE '%' || NVL (cphone, '#noval#') || '%'
    OR accno = (SELECT accno
    FROM requestregistration
    WHERE requestid = creqid)
    UNION
    SELECT TRIM (NAME) AS NAME, TRIM (accno) AS accno,
    TRIM (connaddress) AS connaddress, TRIM (CATEGORY)
    AS CATEGORY,
    TRIM (landmark) AS landmark,
    SUBSTR (accno, 1, 3) AS subdivisionname
    FROM scodetails
    WHERE LOWER (accno) LIKE
    LOWER ('%' || NVL (caccno, '#noval#') || '%')
    OR LOWER (NAME) LIKE LOWER ('%' || NVL (cname, '#noval#') || '%')
    OR LOWER (connaddress) LIKE
    LOWER ('%' || NVL (cadd, '#noval#') || '%')
    OR phone LIKE '%' || NVL (cphone, '#noval#') || '%'
    OR accno = (SELECT accno
    FROM requestregistration
    WHERE requestid = creqid);
    it's ok for small tables but now data increase .......
    searching method is very slow
    now i want to tune this query for better performance
    please sugg me best method
    Thanks in advance
    Regards
    vij..

    The link given by Asif should get you on the right track for tuning this query.
    I just formatted your SQL:
    SELECT Trim(NAME)        AS NAME,
           Trim(accno)       AS accno,
           Trim(connaddress) AS connaddress,
           Trim(category)    AS category,
           Trim(landmark)    AS landmark,
           Substr(accno,1,3) AS subdivisionname
    FROM   consumermaster
    WHERE  Lower(accno) LIKE Lower('%'
                                   ||Nvl(caccno,'#noval#')
                                   ||'%')
            OR Lower(NAME) LIKE Lower('%'
                                      ||Nvl(cname,'#noval#')
                                      ||'%')
            OR Lower(connaddress) LIKE Lower('%'
                                             ||Nvl(cadd,'#noval#')
                                             ||'%')
            OR phone LIKE '%'
                          ||Nvl(cphone,'#noval#')
                          ||'%'
            OR accno = (SELECT accno
                        FROM   requestregistration
                        WHERE  requestid = creqid)
    UNION
    SELECT Trim(NAME)        AS NAME,
           Trim(accno)       AS accno,
           Trim(connaddress) AS connaddress,
           Trim(category)    AS category,
           Trim(landmark)    AS landmark,
           Substr(accno,1,3) AS subdivisionname
    FROM   scodetails
    WHERE  Lower(accno) LIKE Lower('%'
                                   ||Nvl(caccno,'#noval#')
                                   ||'%')
            OR Lower(NAME) LIKE Lower('%'
                                      ||Nvl(cname,'#noval#')
                                      ||'%')
            OR Lower(connaddress) LIKE Lower('%'
                                             ||Nvl(cadd,'#noval#')
                                             ||'%')
            OR phone LIKE '%'
                          ||Nvl(cphone,'#noval#')
                          ||'%'
            OR accno = (SELECT accno
                        FROM   requestregistration
                        WHERE  requestid = creqid); You are using some function on almost each and every column in the where clause. Try getting rid of them as they are hindering the use of indexes, if any, on any of the columns.
    Also the guidelines in the link provided are the best starting point.

  • Simple GUI for simple client needed

    Greetings Gents
    I really need your help here. I have used this Client, and it works fine, but i need to add a GUI interface to it, to make it look professional. Unfortunatly, i am not a programmer, and have no background in programming. All what i need is just a simple Gui, where all typings occur. Can anyone help me, in adding a simple GUi to this client code?
    Your help is really highly appreciated
    best regards
    schwartz
    import java.io.*;
    import java.net.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class Client extends JFrame {
    public static void main(String[] args) throws IOException {
    System.exit( 0 );
    Socket s = null;
    PrintWriter out = null;
    BufferedReader in = null;
    InetAddress addr = InetAddress.getByName(null);
    try {
    s = new Socket(addr, Server.PORT);
    out = new PrintWriter(s.getOutputStream(),true);
    in = new BufferedReader(new InputStreamReader(s.getInputStream()));
    } catch (UnknownHostException e) { System.err.println("Ckeck IP Address on the Host Server");
    System.exit(1);
    } catch
    (IOException e) { System.err.println("Run Server first");
    System.exit(1);
    } BufferedReader stdIn = new BufferedReader(new
    InputStreamReader(System.in));
    String fromServer;
    String fromUser;
    while((fromServer = in.readLine()) != null)
    System.out.println("Server: " + fromServer);
    if (fromServer.equals("Bye")) break;
    fromUser = stdIn.readLine();
    if (fromUser != null)
    { System.out.println("Client: " + fromUser);
    out.println(fromUser);

    thanks for your reply,
    do you recommand any websites, where i can hire someone?

  • Collation problem for sql queries

    Hi All,
    We have 1 old database which have collation "Latin1_General_100_CI_AS".
    We have moved this DB to other server & on for this DB collation is "Latin1_General_100_CS_AS"
    There are lots of SQL procedure we had written & all table,field name in case insensitive manner.
    so for new db it will give us error invalid object name because this db is set as "Latin1_General_100_CS_AS".
    Now we can not change the collation of db.
    so please know us how we can achive case insensitivity for object name in query for "Latin1_General_100_CS_AS" collation.
    please help us we are stucked in big issue & it is not easy to change Store procedure as Senstive name of object.

    Anybody have another suggestion for JK?
    Thanks!
    Ed Price, Azure & Power BI Customer Program Manager (Blog,
    Small Basic,
    Wiki Ninjas,
    Wiki)
    Answer an interesting question?
    Create a wiki article about it!

  • JDBC Bound variable limit for sql queries

    I need to know if there is a limit on the no of variables that can be bound using a prepared Statement ?
    And somebody insisted that the bound variable limit is only when the variables belong to certain types of operators eg:
    A query like this :
    select * from table where column in(?, ?, ?.....)
    cannot have more than 1000 variables but
    a query like this
    select * from table where column in(?, ?, ?) and column1=? and column2=? and column3=? ... and so on ..... can have more than 1000 bound variables ?
    Also is this dependent on the driver or inherent to Oracle versions ?

    Per the Oracle documentation:
    Stage 5: Bind Any Variables At this point, Oracle knows the meaning of the SQL
    statement but still does not have enough information to run the statement. Oracle
    needs values for any variables listed in the statement; in the example, Oracle needs a
    value for department_id. The process of obtaining these values is called binding
    variables.
    A program must specify the location (memory address) where the value can be found.
    End users of applications may be unaware that they are specifying bind variables,
    because the Oracle utility can simply prompt them for a new value.
    Because you specify the location (binding by reference), you need not rebind the
    variable before reexecution. You can change its value and Oracle looks up the value on
    each execution, using the memory address.
    bind variables are stored in the PGA if running a dedicated server. Shared servers use the SGA. The PGA is fixed and OS specific.

  • Simple GUI for ProjectServer

    Hi,
    i need a simple SharePoint-From to create projects with custom fields and show/update projectplan layers (Milestone, Date, Time, Description, Ressource...). Is it possible to do this programmatically? The Projectserver ist to complex for our user
    and the licencecosts for the PWA are very expensive for a simple use. Does anyone have
    other suggestions? Thanks. Chris

    Hi Chris,
    I think you can achieve something without programming anything. It is just a matter of creating a SharePoint list with all required fields (description etc.) and another list for the project tasks and use one of the SharePoint columns to link with the project
    list. You can create multiple lists if you want to manage the project task list using separate lists but it will make a little bit more difficult to manage reporting across all projects and, in the same time, it will make it easier to migrate to project server
    should you want to do so at some stage
    Hope this helps
    Paul

  • Offset and Limit for sql queries

    Hello all,
    Can anybody help me please...
    i have used the offset and limit in postgres sql when we want to get only a number of rows starting from a particular row of a table. is there any similar things available in oracle.
    Hope some one can help me soon...
    Thanks and regards,
    sreejesh Rajan,

    use the following query to get records from 10th row to 14th row
    select * from scott.emp where rownum < 15
    minus
    select * from scott.emp where rownum < 10

  • Simple GUI - Help

    Hi, for my Java class, we have to write a simple GUI for a program that we wrote last week. This is what I have so far:
    import javax.swing.*;
    import java.awt.*;
    import java.util.Random;
    /* Class Kozyra which contains main method */
    public class Kozyra {     
        /* Method question: gets the user to enter whether or not he/she wants to continue
         * running the program */
        public static String question(){
              String s, answer;
              boolean valid;
              do{
                   s = JOptionPane.showInputDialog("Continue? (Y/N or P to Pause)");
                 answer = s.toUpperCase();
                 valid = answer.equals("Y") || answer.equals("N") || answer.equals("P");
                 if(!valid){
                        JOptionPane.showMessageDialog(null, answer + " is not a valid response. Please retype.");
                 } // end if
                 if(answer.equals("P")){
                      JOptionPane.showMessageDialog(null, "Game Paused.  Press OK to continue.");
              }while (!valid); // end do-while
              return answer;
        } // end method question
        public static void frame(){
             Homework3GUI frame = new Homework3GUI();
              frame.setTitle("CRAPS");
              frame.setLocationRelativeTo(null);
             frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              frame.setSize(600,400);
              frame.setLayout(new FlowLayout(FlowLayout.LEFT, 10, 20));
              frame.setVisible(true);
        } // end method frame
        /* Main method: creates new object called player and determines whether or not the game
         * continues running*/
        public static void main(String[] args){     
            frame();
            String answer = "Y";
              Dice player = new Dice(100, "");
              JOptionPane.showMessageDialog(null,"Welcome to CRAPS, " + player.getName());
              while(!player.busted() && !player.reachedGoal() && answer.equals("Y")){           
                player.begin();
                if(!player.busted() && !player.reachedGoal()){
                        answer = question();
                   } // end if
                   else{
                        answer = "N";
                   } // end if
              } // end while                 
        } // end main
    } // end class Homework3
    /* Beginning of class Dice (driver) */
    class Dice extends JPanel{
         // Declare variables
         private int amount, betValue;
         private int roll = 0;
        private String name;
            private boolean win, lose;
            private JTextField text1, text2, text3, text4, text5, text6;
         /* Constructor */
        public Dice(int amount, String name){
            this.name = name; // this refers to instance variabls
            this.amount = amount;
        } // end method Dice
        public void layout(){
             setLayout(new FlowLayout(FlowLayout.LEFT, 10, 20));
             text1 = new JTextField();
             text2 = new JTextField();
             text3 = new JTextField();
             text4 = new JTextField();
             text5 = new JTextField();
             text6 = new JTextField();
             add(text1, null);
             add(text2, null);
             add(text3, null);
             add(text4, null);
             add(text5, null);
             add(text6, null);
             text1.setSize(15,25);
             text2.setSize(15,25);
             text3.setSize(15,25);
             text4.setSize(15,25);
             text5.setSize(15,25);
             text6.setSize(15,25);
             text1.setLocation(10,10);
             text2.setLocation(10,40);
             text3.setLocation(10,70);
             text4.setLocation(10,100);
             text5.setLocation(10,130);
             text6.setLocation(10,160);
             setVisible(true);
        } // end method layout
        /* Prompts the user to enter his/her name using the scanner class and returns it as a string */
        public String getName(){
             String name = JOptionPane.showInputDialog("Please enter your name: ");
            return name;
        } // end method getName
        /* Asks the user to input his/her bet and determines if it is valid */
         private void getBet(){
              String betValueString = JOptionPane.showInputDialog("You have $" + amount +
                   ".  Please enter your bet: $");
              betValue = Integer.parseInt(betValueString);
              if(betValue > amount){
                      betValueString = JOptionPane.showInputDialog("You only have $" + amount +
                           ".  Please enter a bet that is less than or equal to $" + amount + ":  $");
                      betValue = Integer.parseInt(betValueString);
              } // end if
              if(betValue < 1){
                   betValueString = JOptionPane.showInputDialog("You have $" + amount +
                        ".  Please enter an amount greater than $1:  $");
                      betValue = Integer.parseInt(betValueString);
              } // end if
         } // end getBet
         /* Simulates the craps game and returns win */
         private boolean playGame(){
               int answer = roll();
               text1.setText("Your roll is: " + answer);
               win = answer == 11 || answer == 7;
               lose = answer == 2 || answer == 12;
               if(!(win || lose)){
                    int point = answer;
                    text2.setText("Your point value is: "+ point);
                    while(!(win||lose)){
                         answer = roll();
                         text3.setText("Your total is: " + answer);
                         win = answer == point;
                         lose = answer == 7;
                    } // end while
               } // end if
               return win;
          } // end method game
         /* Simulates the rolling of the die */
         public int roll(){
               int die1 = (int)(6*Math.random() + 1);
               int die2 = (int)(6*Math.random() + 1);
               text4.setText("You rolled " + die1 + " and " + die2 + ".  ");
               return die1 + die2;
          } // end method roll
         /* Informs the user of the result of his/her game and updates the amount of "money" */
         private void displayMessage(boolean win){
              if(win == true){
                   text5.setText("Congratulations, you won that round.  You bet $" + betValue +
                        " so you won $" + betValue + ". You now have $" + (amount += betValue));
              } // end if
              else{
                   text5.setText("Sorry, you lost that round.  You bet $" + betValue +
                        " so you lost $" + betValue + ".  You now have $" + (amount -= betValue));
              } // end else if
         } // end method displayMessage
        /* Determines if the user has busted or won and will or will not continue playing */
        public boolean terminate(){
             boolean go;
             if(busted() == true){
                  text6.setText("Sorry, you have lost. :( Somewhere, the world's tiniest violin is " +
                       "playing you a sad song.");
                  go = false;
             } // end if
             else if(reachedGoal() == true){
                  text6.setText("CONGRATULATIONS!  YOU HAVE BEAT THE ODDS AND WON!" +
                       " THE COSMOS SALUTES YOU! GO SPEND YOUR WINNINGS");
                  go = false;
             } // end else if
             else
                  go = true;
             return go;
        } // end method terminate
        /* Determines of goal of amount greater than or equal to $300 has been reached */
        public boolean reachedGoal(){
             return amount >= 300;
        } // end method reachedGoal
        /* Determines if the user has run out of money to play with */
        public boolean busted(){
            return amount <= 0;
        } // end method busted
        /* Calls other methods in order to play game */
        public void begin(){
            getBet();
            playGame();
            displayMessage(win);
            terminate();
        } // end begin
    } // end DiceI'm sure it's simple and terrible and all but I really don't know what I'm doing, and this is my first time writing a GUI (plus my professor's teaching consisted of him telling us to go look online). Firstly I can't get anything to show up on the frame. Secondly, it compiles but does not run and I am getting the following two errors:
    Exception in thread "main" java.lang.NullPointerException
    at Dice.roll(Kozyra.java:182)
    at Dice.playGame(Kozyra.java:155)
    at Dice.begin(Kozyra.java:238)
    at Kozyra.main(Kozyra.java:56)
    Note: C:\Program Files\Xinox Software\JCreatorV4LE\MyProjects\Honors2\Kozyra.java uses or overrides a deprecated API.
    Note: Recompile with -Xlint:deprecation for details.
    Any help would be appreciated, as I am becoming increasingly frustrated (I can't find where the pointer exception is and I have no idea what the "note" one is...). Thanks.

    Thanks, Corlett.
    The Homework3GUI thing was a vestige from something else that I missed correcting. However, I still cannot get anything to show up on the JFrame...Also, what does private static final long serialVersionUID = 54645635L; do?
    This is how the code reads now:
    import javax.swing.*;
    import java.awt.*;
    import java.util.Random;
    public class Kozyra2 extends JFrame{
          // returns true if user wishes to continue playing
         public static boolean playAgain() {
              return JOptionPane.YES_OPTION == JOptionPane.showConfirmDialog(null,
                   "Play again ?", "Do you wish to continue playing?", JOptionPane.YES_NO_OPTION);
          } // end method playAgain
          // builds and shows a GUI.
         public static void buildAndShowGUI(){
              Kozyra2 frame = new Kozyra2();
                 frame.setTitle("CRAPS");
                 frame.setLocationRelativeTo(null);
                 frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                 frame.setSize(600,400);
                frame.setLayout(new FlowLayout(FlowLayout.LEFT, 10, 20));
                 frame.setVisible(true);
          } // end buildAndShowGUI
         // Main method: gets this show on the road.
         public static void main(String[] args){
                buildAndShowGUI();
                Player player = new Player(100, enterName());
              JOptionPane.showMessageDialog(null,"Welcome to CRAPS, " + player.getName());
              while(player.play() && playAgain());
         } // end main method
         // returns the name entered by the user
         private static String enterName() {
              return JOptionPane.showInputDialog("Please enter your name: ");
         } // end method enterName
    } // end class
    class Player extends JPanel{
         private static final long serialVersionUID = 54645635L;
         private static final int TARGET_BALANCE = 300;
         private int balance;
         private String name;
         private JTextField[] text = null;
         public Player(int stake, String name){
              this.name = name;
                 this.balance = stake;
                 this.layoutPanel();
         } // end constructor
         public String getName() {
              return this.name;
         } // end method getName
         private void layoutPanel() {
                setLayout(new FlowLayout(FlowLayout.LEFT, 10, 20));
                 text = new JTextField[6];
                 for (int i=0; i<6; i++) {
                   text[i] = newTextField(10+i*30);
                   add(text, null);
              } // end for loop
              setVisible(true);
         } // end method layoutPanel
         private JTextField newTextField(int y) {
              JTextField t = new JTextField();
              t.setSize(15,25);
              setLocation(10,y);
              return t;
         } // end method newTextField
         // returns the users bet balance
         private int getBet(){
              while (true) {
                   try {
                        String response = JOptionPane.showInputDialog("You have " + balance + ". Your bet ? ");
                        int bet = Integer.parseInt(response);
                        if(bet>=1 && bet<=balance)
                             return bet;
                        JOptionPane.showMessageDialog(null, "Oops: An integer between 1 and " + balance + " is required.");
              } catch (NumberFormatException E) {
                   JOptionPane.showMessageDialog(null, "Oops: An integer value is required.");
              } // end try-catch
              } // end while loop
         } // end method getBet
         // returns true of the user wins this round.
         private boolean playRound(int bet){
              int score = roll();
              text[1].setText("Your score is: " + score);
              boolean win = (score == 11 || score == 7);
              boolean lose = (score == 2 || score == 12);
              int previousScore = score;
              while ( !(win||lose) ) {
                   score = roll();
                   text[3].setText("Your score is: " + score);
              win = (score == previousScore);
              lose = (score == 7);
              previousScore = score;
              } // end while loop
              if (win) {
                   balance += bet;
                   text[5].setText("You won. You won $" + bet + ". You now have $" + balance);
              } // end if statement
              else {
                   balance -= bet;
                   text[5].setText("You lost. You now have $" + balance);
              } // end else
              return win;
         } // end method playRoung
         // returns the total of rolling a pair of dice.
         public int roll(){
              int die1 = (int)(6*Math.random() + 1);
              int die2 = (int)(6*Math.random() + 1);
              int total = die1 + die2;
              text[4].setText("You rolled " + die1 + " and " + die2 + " = " + total);
              return total;
         } // end method roll
    // are we there yet?
         public boolean checkBalance(){
              if (balance <= 0) {
                   text[6].setText("Busted!");
              return true;
              } // end if statement
              if (balance >= TARGET_BALANCE) {
                   text[6].setText("Congratulations! Go spend your winnings.");
                   return true;
              } // end if statement
              return false;
         } // end method checkBalance
         public boolean play(){
              int bet = getBet();
              playRound(bet);
              return checkBalance();
         } // end method play
    } // end class Player

  • Need help in SQL Queries using GUI controls or variables

    Hello, all
    I have a big problem (I have already had with Visual Basic a few mounths ago) with Java while writing my SQL Queries.
    I would like to know how I must do to use variable data or GUI control data in my SQL Query to select only some records.
    Here, my first Query that works without any problem (no WHERE clause !!!) :
    Statement requeteBedes = connectBedes.createStatement();
    ResultSet resultatSeries = requeteBedes.executeQuery("SELECT * FROM Series");
    initComboBoxSeries(resultatSeries);the method "initComboBoxSeries" fills a JComboBox with all the names of the series in my database.
    Here comes my problem.I would like to use the value of the selected "series" in the JComboBox to search in another table of the same Database. I made another statement but it returns a Null ResultSet :
    ResultSet resultatSearchAlbumsFromSeries = requeteBedes.executeQuery("SELECT * FROM bandes_dess WHERE  ser_nom = '" + strComboBoxSeriesSelected + "' "); The variable strComboBoxSeriesSelected contains the value of the selected line in the combobox with all the series, filled after the first query that is here above and that works very well.
    Could some one help me and tell me how I must use variables or GUI controls values in my SQL Queries or tell me if there is a place where I could find an explanation of that kind of problems (like more "advanced SQL Queries", as the ones currently used in all the Learning Java 2 books)
    Thank you all for your help.
    Christian.

    executeQuery() will never return null. At least that's what the spec says. You are probably catching an exception (probably a syntax error caused by a single quote in strComboBoxSeriesSelected) and ignoring it. Or do you mean the ResultSet contains no rows?
    Anyway, to use parameterized queries, take a look at PreparedStatements. Your code should look like this using PreparedStatement:Statement requeteBedes = connectBedes.prepareStatement("SELECT * FROM bandes_dess WHERE  ser_nom = ?");
    requeteBedes.setString(1, strComboBoxSeriesSelected);
    ResultSet resultatSeries = requeteBedes.executeQuery();Alin.

  • Capture @@ROWCOUNT for all QUERIES using SQL AUDIT

    I have a requirement where the customer wants to audit all SELECT queries made to a specific table  and also capture
    "No of rows returned" for these queries made to the table. I was able to capture various SELECT queries happening in the database /Table using SQL AUDIT, Wondering if anybody can suggest how to capture no of rows affected along
    with it, Since we have numerous stored procedures in the system we wont be able to modify existing stored procedures.

    Good day Vish_SQL,
    There are several options that you can use, which fit different cases. for example:
    1. Using extended events (My prefered solution for most cases like this)
    2. Using profiler (older option)
    3. Using view (with the same name as the table, and rename the tables related to the issue) instead of the original table, adding to the view a simple function or SP (CLR for example). the function return the
    column value, but behind the  screen write information to another table. It is a very rare case that you need this option, and I can't recommend
    it.
    4. using applications like GREENSQL which give another level between the application and the SQL Server. The users connect to the server but the server do not listen to remote connection but the external app dose.
    In this case the app get the query and send it t the server (after security or monitoring if you need)
    * it was much simpler if you want to monitor delete, update, or insert for example, since in those cases you could work with AFTER trigger.
    ** I highly recommend you to monitor the application that connect to the SQL Server rather than the SQL Server. if you can.
    Check this:
    http://solutioncenter.apexsql.com/auditing-select-statements-on-sql-server/
      Ronen Ariely
     [Personal Site]    [Blog]    [Facebook]

  • Problem occured when create a tree table for master-detail view objects using SQL queries?

    I am programming a tree table for master-detail view objects using SQL queries and these 2 view objects are not simple singel tables queries, and 2 complex SQL are prepared for master and view objects. see below:
    1. Master View object (key attribute is SourceBlock and some varaible bindings are used for this view object.)
    SELECT  cntr_list.SOURCE_BLOCK,                   
            sum(                   
             case when cntr_list.cntr_size_q = '20'                   
                  then cntr_list.cntr_qty                   
                  else 0 end ) as cntr20 ,                   
            sum(                   
             case when cntr_list.cntr_size_q = '40'                   
                  then cntr_list.cntr_qty                   
                  else 0 end ) as cntr40 ,                   
             sum(                   
             case when cntr_list.cntr_size_q = '45'                   
                  then cntr_list.cntr_qty                   
                  else 0 end ) as cntr45                    
    FROM (       
        SELECT yb1.BLOCK_M as SOURCE_BLOCK,       
               scn.CNTR_SIZE_Q,        
               count(scn.CNTR_SIZE_Q) AS cntr_qty        
        FROM  SHIFT_CMR scm, SHIFT_CNTR scn, YARD_BLOCK yb1, YARD_BLOCK yb2       
        WHERE       
        scm.cmr_n = scn.cmr_n             
        AND (scm.plan_start_dt BETWEEN to_date(:DateFrom,'YYYY/MM/DD HH24:MI:SS') AND to_date(:DateTo,'YYYY/MM/DD HH24:MI:SS')                 
        OR scm.plan_end_dt BETWEEN to_date(:DateFrom,'YYYY/MM/DD HH24:MI:SS') AND to_date(:DateTo,'YYYY/MM/DD HH24:MI:SS'))                 
        AND scm.shift_mode_c = :ShiftModeCode                           
        AND scm.end_terminal_c = :TerminalCode      
        AND scm.start_terminal_c = yb1.terminal_c                  
        AND scm.start_block_n = yb1.block_n                  
        AND substr(scn.start_location_c,(instr(scn.start_location_c,',',1,5)+1),instr(scn.start_location_c,',',1,6)-(instr(scn.start_location_c,',',1,5)+1)) BETWEEN yb1.slot_from_n AND yb1.slot_to_n                  
        AND scm.end_terminal_c = yb2.terminal_c                  
        AND scm.end_block_n = yb2.block_n                  
        AND substr(scn.end_location_c,(instr(scn.end_location_c,',',1,5)+1),instr(scn.end_location_c,',',1,6)-(instr(scn.end_location_c,',',1,5)+1)) BETWEEN yb2.slot_from_n AND yb2.slot_to_n           
        AND scn.status_c not in (1, 11)             
        AND scn.shift_type_c = 'V'             
        AND scn.source_c = 'S'       
        GROUP BY yb1.BLOCK_M, scn.CNTR_SIZE_Q       
    ) cntr_list       
    GROUP BY cntr_list.SOURCE_BLOCK
    2. Detail View object (key attributes are SourceBlock and EndBlock and same varaible bindings are used for this view object.)
    SELECT  cntr_list.SOURCE_BLOCK, cntr_list.END_BLOCK,                
            sum(                     
             case when cntr_list.cntr_size_q = '20'                     
                  then cntr_list.cntr_qty                     
                  else 0 end ) as cntr20 ,                     
            sum(                     
             case when cntr_list.cntr_size_q = '40'                     
                  then cntr_list.cntr_qty                     
                  else 0 end ) as cntr40 ,                     
             sum(                     
             case when cntr_list.cntr_size_q = '45'                     
                  then cntr_list.cntr_qty                     
                  else 0 end ) as cntr45                      
    FROM (         
        SELECT yb1.BLOCK_M as SOURCE_BLOCK,     
               yb2.BLOCK_M as END_BLOCK,  
               scn.CNTR_SIZE_Q,          
               count(scn.CNTR_SIZE_Q) AS cntr_qty          
        FROM  SHIFT_CMR scm, SHIFT_CNTR scn, YARD_BLOCK yb1, YARD_BLOCK yb2         
        WHERE         
        scm.cmr_n = scn.cmr_n               
        AND (scm.plan_start_dt BETWEEN to_date(:DateFrom,'YYYY/MM/DD HH24:MI:SS') AND to_date(:DateTo,'YYYY/MM/DD HH24:MI:SS')                   
        OR scm.plan_end_dt BETWEEN to_date(:DateFrom,'YYYY/MM/DD HH24:MI:SS') AND to_date(:DateTo,'YYYY/MM/DD HH24:MI:SS'))                   
        AND scm.shift_mode_c = :ShiftModeCode                             
        AND scm.end_terminal_c = :TerminalCode        
        AND scm.start_terminal_c = yb1.terminal_c                    
        AND scm.start_block_n = yb1.block_n                    
        AND substr(scn.start_location_c,(instr(scn.start_location_c,',',1,5)+1),instr(scn.start_location_c,',',1,6)-(instr(scn.start_location_c,',',1,5)+1)) BETWEEN yb1.slot_from_n AND yb1.slot_to_n                    
        AND scm.end_terminal_c = yb2.terminal_c                    
        AND scm.end_block_n = yb2.block_n                    
        AND substr(scn.end_location_c,(instr(scn.end_location_c,',',1,5)+1),instr(scn.end_location_c,',',1,6)-(instr(scn.end_location_c,',',1,5)+1)) BETWEEN yb2.slot_from_n AND yb2.slot_to_n             
        AND scn.status_c not in (1, 11)               
        AND scn.shift_type_c = 'V'               
        AND scn.source_c = 'S'         
        GROUP BY yb1.BLOCK_M, yb2.BLOCK_M, scn.CNTR_SIZE_Q         
    ) cntr_list         
    GROUP BY cntr_list.SOURCE_BLOCK, cntr_list.END_BLOCK
    3. I create a view link to create master-detail relationship for these 2 view objects.
    masterview.SourceBlock (1)->detailview.SourceBlock (*).
    4. I create a tree table using these 2 view objects with master-detail relationship.
    When I set default value for variable bindings of these 2 view objects and the matching records exist, tree table can work well. I can expand the master row to display detail row in UI.
    But I need to pass in dymamic parameter value for variable bindings of these 2 view objects, tree table cannnot work again. when I expand the master row and no detail row are displayed in UI.
    I am sure that I pass in correct parameter value for master/detail view objects and matching records exist.
    Managed Bean:
            DCIteratorBinding dc = (DCIteratorBinding)evaluteEL("#{bindings.MasterView1Iterator}");
            ViewObject vo = dc.getViewObject();
            System.out.println("Before MasterView1Iterator vo.getEstimatedRowCount()="+ vo.getEstimatedRowCount());
            System.out.println("Before MasterView1Iterator ShiftModeCode="+ vo.ensureVariableManager().getVariableValue("ShiftModeCode"));
            vo.ensureVariableManager().setVariableValue("DateFrom", dateFrom);
            vo.ensureVariableManager().setVariableValue("DateTo", dateTo);
            vo.ensureVariableManager().setVariableValue("ShiftModeCode", shiftModeC);
            vo.ensureVariableManager().setVariableValue("TerminalCode", terminalCode);
            vo.executeQuery();
            System.out.println("MasterView1Iterator vo.getEstimatedRowCount()="+ vo.getEstimatedRowCount());
            DCIteratorBinding dc1 = (DCIteratorBinding)evaluteEL("#{bindings.DetailView1Iterator}");
            ViewObject vo1 = dc1.getViewObject();
            System.out.println("Before DetailView1Iterator vo1.getEstimatedRowCount()="+ vo1.getEstimatedRowCount());
            System.out.println("Before DetailView1Iterator ShiftModeCode="+ vo1.ensureVariableManager().getVariableValue("ShiftModeCode"));
            vo1.ensureVariableManager().setVariableValue("DateFrom", dateFrom);
            vo1.ensureVariableManager().setVariableValue("DateTo", dateTo);
            vo1.ensureVariableManager().setVariableValue("ShiftModeCode", shiftModeC);
            vo1.ensureVariableManager().setVariableValue("TerminalCode", terminalCode);
            vo1.executeQuery();
            System.out.println("after DetailView1Iterator vo1.getEstimatedRowCount()="+ vo1.getEstimatedRowCount());
    5.  What's wrong in my implementation?  I don't have no problem to implement such a tree table if using simple master-detail tables view object, but now I have to use such 2 view objects using complex SQL for my requirement and variable bindings are necessary for detail view object although I also think a bit strange by myself.

    Hi Frank,
    Thank you and it can work.
    public void setLowHighSalaryRangeForDetailEmployeesAccessorViewObject(Number lowSalary,
                                                                              Number highSalary) {
            Row r = getCurrentRow();
            if (r != null) {
                RowSet rs = (RowSet)r.getAttribute("EmpView");
                if (rs != null) {
                    ViewObject accessorVO = rs.getViewObject();
                    accessorVO.setNamedWhereClauseParam("LowSalary", lowSalary);
                    accessorVO.setNamedWhereClauseParam("HighSalary", highSalary);
                executeQuery();
    but I have a quesiton in this way. in code snippet, it is first getting current row of current master VO to determine if update variables value of detail VO. in my case, current row is possibly null after executeQuery() of master VO and  I have to change current row manually like below.
    any idea?
                DCIteratorBinding dc = (DCIteratorBinding)ADFUtil.evaluateEL("#{bindings.SSForecastSourceBlockView1Iterator}");
                ViewObject vo = dc.getViewObject();           
                vo.ensureVariableManager().setVariableValue("DateFrom", dateFrom);
                vo.ensureVariableManager().setVariableValue("DateTo", dateTo);
                vo.ensureVariableManager().setVariableValue("ShiftModeCode", shiftModeC);
                vo.ensureVariableManager().setVariableValue("TerminalCode", terminalCode);
                vo.executeQuery();
                vo.setCurrentRowAtRangeIndex(0);
                ((SSForecastSourceBlockViewImpl)vo).synchornizeAccessorVOVariableValues();

  • Developing portlets for dummies (sql queries)

    Hello, I've been trying to build a dynamic menu. First I went with just plain old plsql: i created a function in the portal schema that returns an unordered, nested list of the pages in my pagegroup and called that function in a regular pl/sql item on my portal page. I did this by querying the wwpob_page$ table and that went just great in my test&development setup (of which I am the admin of course :))
    Then I realized that since I'm not an administrator of the server hosting our portal and I only have very limited privileges (I am only a page group administrator) I will probably not be allowed to utilize this function nor will they agree to install it in the portal schema, and I decided I should build a portlet that does the same thing (so it can be registered and so on, and so it can use the synonyms and tools that are available to registered providers). There already is such a portlet (and provider) registered for use in the target portal, but I don't like it because i uses tables and hard-coded styles so I will cook my own, better version. :)
    So I downloaded an example portlet and am getting the hang of it, but now I just can't for the life of me figure out how to enable any sql-queries. I have run the provsyns-.sql script, logged in as test_provider/portal and installed my portlet-package as test_provider user. I can see the available pl/sql packages in Toad, but there are no tables or views for me to to see. That means I can't query the portal tables that I need to.
    edit: ok, stupid user error; I suck at using Toad, so I was looking at the wrong schema altogether :D So now i see the public views and packages, so forget that bit of the question.
    But still, I cannot see even wwsbr_all_folders -view, much less the wwpob_page$ -table. I cannot see any way to find the pages that are in my page group. Somehow it must be doable, right?
    Have I done something wrong, missed a step in enabling my test-provider / schema perhaps? I don't really know what I'm doing, but I followed instructions here: http://home.c2i.net/toreingolf/oracle/portal/my_first_plsql_portlet.htm (excellent instructions, thanks!)
    So should my portlet be able to access those tables or not? How the heck has the third partly portlet maker done it?
    i'm on OracleAS Portal 10g Release 2 (10.1.4)
    Edited by: Baguette on 23-Apr-2009 05:13
    Edited by: Baguette on 23-Apr-2009 05:32

    i see your perspective now. and let me give a perspective to my first reply too.
    what i proposed to you was the answer of what i quoted in the message. that is, why didn't you see those views in the new schema you created! and it is still ok but it is done in the portal schema for which you should have privielges too and i assumed you had. my mistake!
    now, i can relate your privacy concerns with your earlier message:
    Hello, I've been trying to build a dynamic menu. First I went with just plain old plsql: i created a function in the portal schema that returns an unordered, nested list of the pages in my pagegroup and called that function in a regular pl/sql item on my portal page. I did this by querying the wwpob_page$ table and that went just great in my test&development setup (of which I am the admin of course :))
    +Then I realized that since I'm not an administrator of the server hosting our portal and I only have very limited privileges (I am only a page group administrator) I will probably not be allowed to utilize this function nor will they agree to install it in the portal schema, and I decided I should build a portlet that does the same thing (so it can be registered and so on, and so it can use the synonyms and tools that are available to registered providers). There already is such a portlet (and provider) registered for use in the target portal, but I don't like it because i uses tables and hard-coded styles so I will cook my own, better version. :)+
    +So I downloaded an example portlet and am getting the hang of it, but now I just can't for the life of me figure out how to enable any sql-queries. I have run the provsyns-.sql script, logged in as test_provider/portal and installed my portlet-package as test_provider user. I can see the available pl/sql packages in Toad, but there are no tables or views for me to to see. That means I can't query the portal tables that I need to.+
    - by downloading an example portlet, you probably mean you created a new schema. because provsyns work on a schema.
    - if you are not the administrator of the portal, and may not be able to access some portions of the portal, it means that you do not use the portal user (the user which serves as the owner of the portal schema).
    - now, your plan to create a new schema and give those privielges would still not work. because, by creating a new schema you cannot sneak in to the oriignal portal schema if you do not have privileges to do it. obvious, right? otherwise, it would be a vulnerability of the software that you can see what you are not allowed to see by creating a new schema.
    - however, there is a bright side here. the views give records based on your privileges.
    - so if your administrators have generated them already or if they generate on the original portal schema, then you may see the pages and items that you have privileges to see and no more.
    so now, you may ask the administrators if they have already done it, and if not, then if they would be willing to do it.
    hope that helps!
    AMN

Maybe you are looking for

  • Browsers unable to load pages after upgrade to 8.1

    which forum would I post to get help with this please? Thanks.

  • Error with connetion(pool) to database (Entity JavaEE)

    Please help me , I try config pool but not working .I run on other computer(win xp) very good ,so I think glassfish on my computer(win 7) some error . This is my error: WARNING: RAR5117 : Failed to obtain/create connection from connection pool [ eSto

  • IOS 8 no longer works with 2012 honda accord

    I upgraded my iPhone 5 to iOS 8.0.2.  When I connect via USB, I no longer am able to use my car (2012 Honda Accord) controls to play music.  Also, while it does connect via BlueTooth, making phone calls is very difficult, it takes much longer to conn

  • New iphone, intermittent "no service" indoors in good reception area

    Hi. I'm new here. I've had an iPhone 4 for over 2 years on O2 in the UK, and I've always been able to use it indoors at home. Yesterday, I received my brand new SIM-free iPhone 5, and I plugged in my new Vodafone pay-monthly nano SIM. I moved to Voda

  • Changing file multiple file names and extensions

    hi all i have just converted a couple of files with some software, but it hasnt put the file extension on, does anyone know of a way to automatically change them, they are already mp4 files but missing the .mp4 on the name part, can anyone help me ou