MySQL 4.1 SubQuery Problem

Hello,
I switched from MySQL 4.0.x to 4.1.x to have subquery support.
It seems to work but it looks like that the kodo generated sql
code misses the derived table name for a "count(*)" query.
It produces this which does not work :
SELECT COUNT(?) FROM
SELECT DISTINCT t0.ID AS t0_ID FROM customer t0 INNER JOIN
custo_advertiser t1 ON t0.ID = t1.ID WHERE
(t1.ELEMENT = ? AND t0.MAINNETWORK = ? AND t0.SUBNETWORK = ?)
ErrorMessage : kodo.util.UserException:
com.solarmetric.jdbc.ReportingSQLException: Syntax error or access
violation, message from server: "Every derived table must have its own
alias" {prepstmnt 29234933 SELECT COUNT(?) FROM (SELECT DISTINCT t0.ID AS
t0_ID FROM customer t0 INNER JOIN custo_advertiser t1 ON t0.ID = t1.ID
WHERE (t1.ELEMENT = ? AND t0.MAINNETWORK = ? AND t0.SUBNETWORK = ?))
[reused=0]} [code=1248, state=42000]
This code works after I added name for the derived table result :
SELECT COUNT(*) FROM
SELECT DISTINCT t0.ID AS t0_ID FROM customer t0
INNER JOIN custo_advertiser t1 ON t0.ID = t1.ID
WHERE (t1.ELEMENT = 6 AND t0.MAINNETWORK = 36 AND t0.SUBNETWORK = 1)
) derived_table_name
Is there a way to get kodo to add the derived table name?
Regards,
Mark

Mark wrote:
That is what MySql has on their page about this issue :
http://dev.mysql.com/doc/mysql/en/Unnamed_views.html
Regards,
Mark
Hello,
I switched from MySQL 4.0.x to 4.1.x to have subquery support.
It seems to work but it looks like that the kodo generated sql
code misses the derived table name for a "count(*)" query.
It produces this which does not work :
SELECT COUNT(?) FROM
SELECT DISTINCT t0.ID AS t0_ID FROM customer t0 INNER JOIN
custo_advertiser t1 ON t0.ID = t1.ID WHERE
(t1.ELEMENT = ? AND t0.MAINNETWORK = ? AND t0.SUBNETWORK = ?)
ErrorMessage : kodo.util.UserException:
com.solarmetric.jdbc.ReportingSQLException: Syntax error or access
violation, message from server: "Every derived table must have its own
alias" {prepstmnt 29234933 SELECT COUNT(?) FROM (SELECT DISTINCT t0.ID AS
t0_ID FROM customer t0 INNER JOIN custo_advertiser t1 ON t0.ID = t1.ID
WHERE (t1.ELEMENT = ? AND t0.MAINNETWORK = ? AND t0.SUBNETWORK = ?))
[reused=0]} [code=1248, state=42000]
This code works after I added name for the derived table result :
SELECT COUNT(*) FROM
SELECT DISTINCT t0.ID AS t0_ID FROM customer t0
INNER JOIN custo_advertiser t1 ON t0.ID = t1.ID
WHERE (t1.ELEMENT = 6 AND t0.MAINNETWORK = 36 AND t0.SUBNETWORK = 1)
) derived_table_name
Is there a way to get kodo to add the derived table name?
Regards,
Mark

Similar Messages

  • Oracle to Mysql character set conversion problem!!! PLZ IGNORE

    Hi Experts,
    I have created a database link from Oracle 10g to Mysql 5.
    I have installed Oracle Gateway 11g for this purpose.
    When i retreive the data from sql plus the text is displayed as question marks.
    Oracle 10g Database character set is WE8MSWIN1252
    Mysql character set --->latin1
    Character set of ODBC connector for mysql is  latin7
    Character set in the parameter file of HS folder is WE8MSWIN1252When i retrieve data from sql developer the text is fine(as i think it directly takes the character set of target) but
    when i login from sqlplus i get question marks!
    I have another post in Heterogeneous Connectivity forum
    Re: Oracle to Mysql character set conversion problem!!! PLZ HELP
    Kindly update your comments there,
    @@@@@@@@@@@@@@2
    Appreciate your help,
    regards
    Edited by: user10243788 on Apr 21, 2010 3:25 AM

    It is OK to post a globalization-related question in this forum in addition to the forum pertaining to the main technology. Not all experts follow all possible forums on OTN. Of course, you should cross-link the posts to let people merge the answers.
    Regarding the problem itself, make sure that SQL*Plus has the right NLS_LANG setting in the environment. On Windows, in the Command Prompt:
    C:\> set NLS_LANG=.WE8PC850
    C:\> sqlplus ...On Unix:
    $ setenv NLS_LANG .WE8ISO8859P1   (or NLS_LANG=.WE8ISO8859P1; export NLS_LANG)
    $ sqlplus ...-- Sergiusz

  • MySQL & Sun ONE studio problem

    hello all,
    It seemed like I've got the data source & database driver stuff setup to work with MySQL database in Sun ONE studio. However, when I tried to run the helloworld_TestApp (CMP App), I've got the SQL syntax error. I tried to look at the sun-j2ee-ri.xml, and it looked just fine to me.. please help.
    Here is the XML descriptor
    <?xml version="1.0" encoding="UTF-8"?>
    <j2ee-ri-specific-information>
    <server-name></server-name>
    <rolemapping/>
    <web>
    <display-name>helloworld_TestApp</display-name>
    <servlet>
    <servlet-name>dispatch</servlet-name>
    </servlet>
    <servlet>
    <servlet-name>error</servlet-name>
    </servlet>
    <servlet>
    <servlet-name>viewer</servlet-name>
    </servlet>
    <context-root>helloworld_TestApp</context-root>
    <ejb-ref>
    <ejb-ref-name>ejb/TestedEJB</ejb-ref-name>
    <jndi-name>helloworld</jndi-name>
    </ejb-ref>
    </web>
    <enterprise-beans>
    <unique-id>1</unique-id>
    <ejb>
    <ejb-name>helloworld</ejb-name>
    <jndi-name>helloworld</jndi-name>
    <ejb20-cmp>
    <sql-statement>
    <operation>loadRow</operation>
    <sql>SELECT "lastname" FROM "helloworld" WHERE "firstname" = ? </sql>
    </sql-statement>
    <sql-statement>
    <operation>storeRow</operation>
    <sql>UPDATE "helloworld" SET "lastname" = ? WHERE "firstname" = ? </sql>
    </sql-statement>
    <sql-statement>
    <operation>deleteRow</operation>
    <sql>DELETE FROM "helloworld" WHERE "firstname" = ? </sql>
    </sql-statement>
    <sql-statement>
    <operation>deleteTable</operation>
    <sql>DROP TABLE "helloworld"</sql>
    </sql-statement>
    <sql-statement>
    <operation>findByPrimaryKey</operation>
    <sql>SELECT "firstname" FROM "helloworld" WHERE "firstname" = ? </sql>
    </sql-statement>
    <sql-statement>
    <operation>createRow</operation>
    <sql>INSERT INTO "helloworld" ( "firstname" , "lastname" ) VALUES ( ? , ? )</sql>
    </sql-statement>
    <sql-statement>
    <operation>createTable</operation>
    <sql>CREATE TABLE "helloworld" ("firstname" VARCHAR(255) NOT NULL , "lastname" VARCHAR(255), CONSTRAINT "pk_helloworl" PRIMARY KEY ("firstname") )</sql>
    </sql-statement>
    <create-table-deploy>true</create-table-deploy>
    <delete-table-undeploy>false</delete-table-undeploy>
    </ejb20-cmp>
    <principal>
    <name></name>
    </principal>
    <ior-security-config>
    <transport-config>
    <integrity>supported</integrity>
    <confidentiality>supported</confidentiality>
    <establish-trust-in-target>supported</establish-trust-in-target>
    <establish-trust-in-client>supported</establish-trust-in-client>
    </transport-config>
    <as-context>
    <auth-method>username_password</auth-method>
    <realm>default</realm>
    <required>true</required>
    </as-context>
    <sas-context>
    <caller-propagation>supported</caller-propagation>
    </sas-context>
    </ior-security-config>
    </ejb>
    <cmpresource>
    <ds-jndi-name>jdbc/MySQL</ds-jndi-name>
    <default-resource-principal>
    <name>root</name>
    <password>root</password>
    </default-resource-principal>
    </cmpresource>
    </enterprise-beans>
    </j2ee-ri-specific-information>
    And here is the error message:
    The exception java.rmi.ServerException was thrown when invoking findByPrimaryKey with parameters:
    thinh
    Following is the stack trace:
    java.rmi.ServerException: RemoteException occurred in server thread; nested exception is: java.rmi.RemoteException: nested exception is: java.sql.SQLException: Syntax error or access violation: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '"helloworld" WHERE "firstname" = 'thinh'' at line 1; nested exception is: java.sql.SQLException: Syntax error or access violation: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '"helloworld" WHERE "firstname" = 'thinh'' at line 1 at com.sun.corba.ee.internal.javax.rmi.CORBA.Util.wrapException(Util.java:345) at javax.rmi.CORBA.Util.wrapException(Util.java:277) at ..
    ...more and more..

    Where are you running your application? I assume you
    are running your application on RI. Are you running
    on RI or S1AS?I am running my application on R1, is there a problem with it? can the S1AS solve the problem?
    Thanks & regards,
    Tim

  • MySQL connection pooling (tomcat) problem

    Hi all i just started learning servlets and i want to make a program in order to understand database connection pooling in tomcat.My problem is that when i run the servlet i created i get this error :
    java.lang.NullPointerException org.DB.TestDB2.doGet(TestDB2.java:105) javax.servlet.http.HttpServlet.service(HttpServlet.java:690) javax.servlet.http.HttpServlet.service(HttpServlet.java:803) org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:390)
    And that from tomcat log from netbeans :
    org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create JDBC driver of class '' for connect URL 'null' 
    .I configured tomcat server.xml file like this :
    <Context path="/DBTest" docBase="DBTest"         debug="5" reloadable="true" crossContext="true">   <Resource name="jdbc/phonebook_db" auth="Container" type="javax.sql.DataSource"               maxActive="100" maxIdle="30" maxWait="10000"               username="*******" password="********" removeAbandoned="true"               removeAbandonedTimeout="120" driverClassName="com.mysql.jdbc.Driver"               url="jdbc:mysql://localhost:3306/test_phonebook_db?autoReconnect=true"/> </Context>   
    This is the resource reference i have in my web app web.xml file :
    <resource-ref>       <description>DB Connection</description>       <res-ref-name>jdbc/phonebook_db</res-ref-name>       <res-type>javax.sql.DataSource</res-type>       <res-auth>Container</res-auth>   </resource-ref> 
    And this is my servlet class :
    package org.DB;  import javax.servlet.*; import javax.servlet.http.*; import java.io.*; import java.sql.*; import javax.naming.*; import javax.sql.*; public class TestDB2 extends HttpServlet { private Connection conn ; private Statement stat ; private ResultSet rs ; private int counter; private Object rsValue; public void init() {     try {             InitialContext ctx = new InitialContext();             DataSource ds = (DataSource)ctx.lookup("java:comp/env/jdbc/phonebook_db");             conn = ds.getConnection();             }         catch(Exception e) {               e.printStackTrace();         }     }     public void doGet(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException {         try {           stat = conn.createStatement();           rs = stat.executeQuery("SELECT * FROM phones_table");            } catch (SQLException sqle) {         sqle.printStackTrace();         }      response.setContentType("text/html; charset=utf-8");     PrintWriter out = response.getWriter();         String docType = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 " + "Transitional//EN\">\n";     out.println(docType +"<HTML>\n" + "<HEAD><TITLE>PhoneBook entries</TITLE></HEAD>\n");         counter = 0;     try {         while (rs.next()) {             out.println("<h4>Entry no. " + (++counter) + "</h4>");             out.println("<table width=\"75%\" border=\"1\">");             out.println("<tr>\n"+ "<td width=\21%\"><b>LastName:</b></td>\n"+ "<td width=\"79%\">");             out.println((((rsValue = rs.getObject("LASTNAME"))==null || rs.wasNull())?                 "":(rsValue.toString())));             out.println("</td>\n</tr>\n" +  "<tr>\n"+                     "<td width=\21%\"><b>FirstName:</b></td>\n"+ "<td width=\"79%\">");             out.println((((rsValue = rs.getObject("FIRSTNAME"))==null || rs.wasNull())?                 "":(rsValue.toString())));             out.println("</td>\n"+ "</tr>\n"+                     "<td width=\21%\"><b>Phone:</b></td>\n"+ "<td width=\"79%\">");             out.println((((rsValue = rs.getObject("PHONE"))==null || rs.wasNull())?                 "":(rsValue.toString())));             out.println("</td>\n" + "</tr>\n" +                     "</table>\n"+ "<br>\n<br>");         }     } catch (SQLException sqle) {         sqle.printStackTrace();     }     out.println("</body>\n"+             "</html>"); } public void destroy() {     try {         rs.close();         stat.close();         conn.close();     } catch (SQLException sqle) {         sqle.printStackTrace();         }     } }{code} Any suggestions?                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

    Thank you for your answer.Yes my servlet class is something more worse than horrible(i don't use the database connection correct i don't use the MVC pattern i use out.println() ) but i just tried to take a ready example and try to understand .So i write this servlet myself as a starting point :
    package org.DB;
    import javax.servlet.ServletException;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import java.io.*;
    import java.sql.*;
    public class DBServlet extends HttpServlet {
        private Connection conn ;
        private Statement stat ;
        private ResultSet rs ;
        private int counter;
        String driver = "com.mysql.jdbc.Driver";
        String dbURL = "jdbc:mysql://localhost:3306/phonebookdb?user=**********&password=************";
        @Override
    public void init() {
         try {
                Class.forName(driver).newInstance();
                conn = DriverManager.getConnection(dbURL);
         }catch(Exception e) {
                  e.printStackTrace();
                  System.err.print("Unable to make connection ");
        protected void processRequest(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
            response.setContentType("text/html;charset=UTF-8");
            PrintWriter out = response.getWriter();
            try {
                out.println("<html>");
                out.println("<head>");
                out.println("<title>Servlet DBServlet</title>"); 
                out.println("</head>");
                out.println("<body>");
                out.println("<h1>Servlet DBServlet at " + request.getContextPath () + "</h1>");
                out.println("<br /><br /><br />");
                if(conn!=null) 
                    out.println("conn object : "+conn);
                out.println("</body>");
                out.println("</html>");
            } catch(Exception sq) {
                System.out.println("Exception" + sq.getMessage());
                out.close();
        @Override
        protected void doGet(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
            processRequest(request, response);
        @Override
        protected void doPost(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
            processRequest(request, response);
         public void destroy() {
         try {
             conn.close();
         } catch (SQLException sqle) {
             sqle.printStackTrace();
        @Override
        public String getServletInfo() {
            return "A Simple Servlet";
    }And it work for now.
    Edited by: pavlos555 on Oct 21, 2008 10:21 AM

  • Oracle to Mysql character set conversion problem!!! PLZ HELP

    Hi Experts,
    I have created a database link from Oracle 10g to Mysql 5.
    I have installed Oracle Gateway 11g for this purpose.
    When i retreive the data from sql plus the text is displayed as question marks.
    Oracle 10g Database character set is WE8MSWIN1252
    Mysql character set --->latin1
    Character set of ODBC connector for mysql is  latin7
    Character set in the parameter file of HS folder is WE8MSWIN1252When i retrieve data from sql developer the text is fine(as i think it directly takes the character set of target) but
    when i login from sqlplus i get question marks!
    Appreciate your help,
    regards

    thank you for replying damorgan,
    my previous two threads in the "heterogeneous Connectivity" forum were for different issues, one was to enquire as to how i could connect from oracle to mysql(which i have marked as answered), the other is for error when i get when i tried accessing data(which i am still facing on my office machine ).
    I followed the steps from these two threads and was able to successfully connect to mysql on my personal PC at home, but faced some problem with text not displayed so i created this thread.
    I had created another thread similar to this in the globalisation support as i was facing issue with the character sets in a heterogenous setup, so wasen't clear as to which forum would be suitable for this issue.
    My apologies to everyone if this has offended you.

  • Subquery problem

    I am trying to use a subquery where rownum =1 and have and order by to get the most recent record. If I do this:
    SELECT A1,
    (SELECT C1 FROM T2 WHERE C2=T1.C1 AND ROWNUM=1) AS X
    FROM T1
    I get a random row, so I tried this:
    SELECT A1,
    SELECT * FROM (SELECT C1 FROM T2 WHERE C2=T1.C1 ORDER BY C3 DESC) WHERE ROWNUM=1)) AS X
    FROM T1
    and I get an error saying T1.C1 is invalid. Is there a way to do this?
    Thanks.

    You have one opening bracket and three closing brackets. That's not a good sign ;)
    The deeper problem is that a subquery cannot refer to its grandparent; e.g. this is OK:
    SELECT dummy
         , ( SELECT t1.dummy
             FROM   ( SELECT dummy c1
                      FROM   dual
                      WHERE  dummy = 'X'  -- uncorrelated
                      ORDER  BY dummy DESC )
             WHERE  rownum = 1 ) AS x
    FROM  dual t1;but this is not:
    SELECT dummy
         , ( SELECT t1.dummy
             FROM   ( SELECT dummy c1
                      FROM   dual
                      WHERE  dummy = t1.dummy
                      ORDER  BY dummy DESC )
             WHERE  rownum = 1 ) AS x
    FROM  dual t1;
    ERROR at line 5:
    ORA-00904: "T1"."DUMMY": invalid identifier

  • Mysql oracle migration capture problem

    I have problem during capture database.
    I don't know it working or not working after catalog, schema, table object capturing.
    It seems stop.
    mysql have only one table and one record.
    MYSQL version : 6.0
    ORCLE version : 10g
    SQL Developer : 1.2
    Message was edited by:
    user613482

    Mysql version 6 is not yet supported for migration. Support exists only for versions 3,4 and 5.
    - Rakesh

  • Applet connecting to Mysql on serverside?problem

    hi all
    i am having some problem in Applet
    The problem is i am drawing on an applet.
    which is taking input from database(Mysql)
    it is running fine on konsol in appletviewer,
    but when i run in Browser(NetScape 4.*) it is giving error
    Applet not started , code is as follows
    /*<applet code="AppletSql" width=100 height=100></applet>*/
    import java.sql.*;
    import java.awt.*;
    import java.applet.*;
    import java.awt.event.*;
    import org.gjt.mm.mysql.Driver;
    public class AppletSql extends Applet{
    Exception e1;
    Button b ;
    public void init(){
    try{
    Class.forName("org.gjt.mm.mysql.Driver").newInstance();
    }catch(Exception e){}
    b= new Button("Hi");
    add(b);
    i am using Tomcat as my server, now i am keeping my this applet in my /usr/local/jakarta..../weapps/examples/jsp .is it the problem of my server, do i have to configure my server for mysql-connector..
    or is it like this as appets are running on client side,so u cannot
    connect to Drivers on Server,or i have to write socket prog.. for
    connecting to Applet can i do the same thing swings or beans,or can i draw graphics with beans
    Thanking you
    sunil

    In your html page, you need to have the applet tag e.g
    <applet code="classname" codebase="serverurl" height="" width="">
    </applet>

  • Access MySQL from Oracle Tnsping problem.

    Dears
    I am trying to connect to MysqlDB from Oracle.
    I have installed Oracle Gateway and ODBC diver on Linux server.
    Oracle gateway was installed on same server with Oracle Database but in different home and it has a different listener.
    please look at my configuration files which I have created and maintained to established connections to MySqlDB.
    I think I did some mistake and seize up in it so I could not find a solution. I am trying to fix it as well but if somebody can help me it will be very nice.
    Gateway version is 11.2.0.3.0 and it is on ORAHOME /oracle/11203/GTW and its listener port is 1522.
    I am able to tnsping port 1522 (dg4odbc) from gateways home. Gateway configuration files are below.
    ####/etc/odbc.ini####
    [ODBC Data Sources]
    MySQL = MySQL ODBC Driver 5.2
    [MySQL]
    Driver = /usr/lib64/libmyodbc5a.so
    DATABASE = veritabani
    DESCRIPTION = MySQL ODBC 5.2 Driver
    PORT = nnnn
    SERVER = x.x.x.x
    UID = kullanici
    PWD = sifre
    CHARSET = latin1
    TRACEFILE = /tmp/myodbc-demodsn.trc
    TRACE = OFF
    ####/oracle/11203/GTW/hs/admin/initdg4odbc.ora####
    HS_FDS_CONNECT_INFO = MySQL
    HS_FDS_TRACE_LEVEL = 0
    HS_FDS_SHAREABLE_NAME = /usr/lib64/libmyodbc5a.so
    set ODBCINI=/etc/odbc.ini
    set HOME=/home/oracle
    ####/oracle/11203/GTW/network/admin/listener.ora####
    LISTENER =
    (ADDRESS_LIST=
    (ADDRESS=(PROTOCOL=tcp)(HOST=hostname)(PORT=1522))
    SID_LIST_LISTENER=
    (SID_LIST=
    (SID_DESC=
    (SID_NAME=dg4odbc)
    (ORACLE_HOME=/oracle/11203/GTW)
    (PROGRAM=dg4odbc)
    (ENVS=LD_LIBRARY_PATH=/usr/lib64:/oracle/11203/GTW/lib)
    ####/oracle/11203/GTW/network/admin/tnsnames.ora####
    dg4odbc =
    (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)
    (HOST = hostname)
    (PORT = 1522)
    (CONNECT_DATA =
    (SID = dg4odbc)
    (HS = OK)
    Oracle Database version is 11.2.0.2.0 and Its on ORAHOME /oracle/11202/BDW and its listener port is 1521.
    I am not able to tnsping port 1522 (dg4odbc) from Database Home. Database configuration file is below.
    ####/oracle/11202/BDW/network/admin/tnsnames.ora####
    dg4odbc =
    (DESCRIPTION =
    (ADDRESS_LIST =
    (ADDRESS = (PROTOCOL = TCP)(HOST = hostname)(PORT = 1522)))
    (CONNECT_DATA = (SID = dg4odbc))
    (HS=OK))
    Also I have created a DBLINK and tried to get info from MySqlDB but it did not work as usual.
    CREATE PUBLIC DATABASE LINK dg4odbc CONNECT TO "kullanici" IDENTIFIED BY "sifre" USING ’dg4odbc’;
    SQL> select * from kullanici@dg4odbc;
    select * from kullanici@dg4odbc
    ERROR at line 1:
    ora-12154 tns could not resolve the connect identifier specified
    Thank you so much to everybody who reads and writes this...
    Best regards,
    Eren.
    Edited by: BeymenAdmin on Mar 21, 2013 8:52 AM

    BeymenAdmin wrote:
    Dears
    I am trying to connect to MysqlDB from Oracle.
    I have installed Oracle Gateway and ODBC diver on Linux server.
    Oracle gateway was installed on same server with Oracle Database but in different home and it has a different listener.
    please look at my configuration files which I have created and maintained to established connections to MySqlDB.
    I think I did some mistake and seize up in it so I could not find a solution. I am trying to fix it as well but if somebody can help me it will be very nice.
    Gateway version is 11.2.0.3.0 and it is on ORAHOME /oracle/11203/GTW and its listener port is 1522.
    I am able to tnsping port 1522 (dg4odbc) from gateways home. Gateway configuration files are below.
    ####/etc/odbc.ini####
    [ODBC Data Sources]
    MySQL = MySQL ODBC Driver 5.2
    [MySQL]
    Driver = /usr/lib64/libmyodbc5a.so
    DATABASE = veritabani
    DESCRIPTION = MySQL ODBC 5.2 Driver
    PORT = nnnn
    SERVER = x.x.x.x
    UID = kullanici
    PWD = sifre
    CHARSET = latin1
    TRACEFILE = /tmp/myodbc-demodsn.trc
    TRACE = OFF
    ####/oracle/11203/GTW/hs/admin/initdg4odbc.ora####
    HS_FDS_CONNECT_INFO = MySQL
    HS_FDS_TRACE_LEVEL = 0
    HS_FDS_SHAREABLE_NAME = /usr/lib64/libmyodbc5a.so
    set ODBCINI=/etc/odbc.ini
    set HOME=/home/oracle
    ####/oracle/11203/GTW/network/admin/listener.ora####
    LISTENER =
    (ADDRESS_LIST=
    (ADDRESS=(PROTOCOL=tcp)(HOST=hostname)(PORT=1522))
    SID_LIST_LISTENER=
    (SID_LIST=
    (SID_DESC=
    (SID_NAME=dg4odbc)
    (ORACLE_HOME=/oracle/11203/GTW)
    (PROGRAM=dg4odbc)
    (ENVS=LD_LIBRARY_PATH=/usr/lib64:/oracle/11203/GTW/lib)
    ####/oracle/11203/GTW/network/admin/tnsnames.ora####
    dg4odbc =
    (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)
    (HOST = hostname)
    (PORT = 1522)
    (CONNECT_DATA =
    (SID = dg4odbc)
    (HS = OK)
    Oracle Database version is 11.2.0.2.0 and Its on ORAHOME /oracle/11202/BDW and its listener port is 1521.
    I am not able to tnsping port 1522 (dg4odbc) from Database Home. Database configuration file is below.
    ####/oracle/11202/BDW/network/admin/tnsnames.ora####
    dg4odbc =
    (DESCRIPTION =
    (ADDRESS_LIST =
    (ADDRESS = (PROTOCOL = TCP)(HOST = hostname)(PORT = 1522)))
    (CONNECT_DATA = (SID = dg4odbc))
    (HS=OK))
    Also I have created a DBLINK and tried to get info from MySqlDB but it did not work as usual.
    CREATE PUBLIC DATABASE LINK dg4odbc CONNECT TO "kullanici" IDENTIFIED BY "sifre" USING ’dg4odbc’;
    SQL> select * from kullanici@dg4odbc;
    select * from kullanici@dg4odbc
    ERROR at line 1:
    ora-12154 tns could not resolve the connect identifier specified
    see: [url http://edstevensdba.wordpress.com/2011/02/26/ora-12154tns-03505/] ora-12154 TNS:could not resolve the connect identifier specified
    Remember that the database from which you issued the "select * from kullanici@dg4odbc;" is, at that point, acting just like any other client trying to connect to a remote database.
    Thank you so much to everybody who reads and writes this...
    Best regards,
    Eren.
    Edited by: BeymenAdmin on Mar 21, 2013 8:52 AM

  • Mysql connection through netbeans problem

    Hi All - I am trying to connect to a mysql database using the following:
    Connection con = DriverManager.getConnection("jdbc:mysql://localhost/database?" +
                        "user=user&password=pass");But am getting an error of: SQLException: No suitable driver found for jdbc:mysql://local...
    I have downloaded MySQL Connector/J and have added it to the netbeans project libraries and still nothing works. Has anyone any idea what I am doing wrong? Thanks

    Because you haven't loaded the Driver yet, either with Class.forName or DriverManager.registerDriver.
    Also, I hope your user is really "user" and your password really "pass", because if "user" and "pass" are variables names that url won't work anyway. And, in anycase, you're better off using the getConnection(url, user, pass) form of getConnection anyway.

  • Subquery problems with ordering data

    I need to order my data by an index. But I am pulling the data from three different tables and I'm new to SQL and using someone else's query. His original query is:
    WITH subquery AS
    (SELECT t1.smpl_dte, t1.pv_id,
    t1.integ_over_val
    FROM diag.blm_acct t1
    WHERE smpl_dte BETWEEN to_date('start', 'MM-DD-
    YYYY HH:MI:SS AM')
    AND to_date('end', 'MM-DD-YYYY HH:MI:SS AM'))
    SELECT t2.sgnl_id,
    SUM(subquery.integ_over_val) sumval
    FROM diag.pv_sgnl_id_assc t2,
    subquery
    WHERE t2.pv_id = subquery.pv_id
    AND sgnl_id IN(PVS)
    GROUP BY t2.sgnl_id
    In this query 'start' and 'end' are dates. PVS is a placeholder for a list of strings (see modified query below). This returns two columns, one of Strings, the other of floats. But I also need a third column which has the index of the item. The index is located in a separate table called diag.series_sgnl_rec_asgn which has three fields series_id(String), sgnl_id(String), and disp_ord_nbr (number). The sgnl_id is the same as that returned by the first query. I need to pull out all the sgnl_ids from this table that are equal to some series_id.
    Here was my attempt to get the index (disp_ord_nbr) into the results:
    WITH subquery AS
    (SELECT t1.smpl_dte, t1.pv_id,
    t1.integ_over_val
    FROM diag.blm_acct t1
    WHERE smpl_dte BETWEEN to_date('09/01/2008 12:00:00 AM', 'MM-DD-
    YYYY HH:MI:SS AM')
    AND to_date('09/02/2008 12:00:00 AM', 'MM-DD-YYYY HH:MI:SS AM')
    SELECT t2.sgnl_id,
    ser.disp_ord_nbr,
    SUM(subquery.integ_over_val) sumval
    FROM diag.pv_sgnl_id_assc t2,
    diag.series_sgnl_rec_asgn ser
    WHERE t2.pv_id = subquery.pv_id
    AND ser.disp_ord_nbr = 'Series11'
    AND t2.sgnl_id IN('Ring_Diag:BLM_A11c:Slow60PulsesTotalLoss',
    'Ring_Diag:BLM_A11d:Slow60PulsesTotalLoss', 'Ring_Diag:BLM_A11e:Slow60PulsesTotalLoss',
    'Ring_Diag:BLM_A13:Slow60PulsesTotalLoss', 'Ring_Diag:BLM_A13b:Slow60PulsesTotalLoss',
    'Ring_Diag:BLM_B01:Slow60PulsesTotalLoss', 'Ring_Diag:BLM_B02:Slow60PulsesTotalLoss',
    'Ring_Diag:BLM_B03:Slow60PulsesTotalLoss', 'Ring_Diag:BLM_B04:Slow60PulsesTotalLoss')
    GROUP BY t2.sgnl_id
    Any help would be greatly appreciated!
    Thanks.

    Try this:
    SELECT t2.sgnl_id,
           SUM(subquery.integ_over_val) sumval
      FROM diag.pv_sgnl_id_assc t2,
           diag.series_sgnl_rec_asgn ser,
          (SELECT t1.smpl_dte,
                  t1.pv_id,
                  t1.integ_over_val
             FROM diag.blm_acct t1
            WHERE smpl_dte BETWEEN to_date('09/01/2008 12:00:00 AM',    'MM-DD-YYYY HH:MI:SS AM')
                               AND to_date('09/02/2008 12:00:00 AM',    'MM-DD-YYYY HH:MI:SS AM')) subquery
    WHERE t2.pv_id         = subquery.pv_id
       AND t2.sgnl_id       = ser.sgnl_id
       AND ser.disp_ord_nbr = 'Series11'
       AND t2.sgnl_id IN('Ring_Diag:BLM_A11c:Slow60PulsesTotalLoss',  
                         'Ring_Diag:BLM_A11d:Slow60PulsesTotalLoss',  
                         'Ring_Diag:BLM_A11e:Slow60PulsesTotalLoss',  
                         'Ring_Diag:BLM_A13:Slow60PulsesTotalLoss',  
                         'Ring_Diag:BLM_A13b:Slow60PulsesTotalLoss',  
                         'Ring_Diag:BLM_B01:Slow60PulsesTotalLoss',  
                         'Ring_Diag:BLM_B02:Slow60PulsesTotalLoss',  
                         'Ring_Diag:BLM_B03:Slow60PulsesTotalLoss',  
                         'Ring_Diag:BLM_B04:Slow60PulsesTotalLoss')
    GROUP BY t2.sgnl_id;

  • MySQL Oracle DB link problem

    Hi,
    I'm running Oracle 11g 64bit on Windows machine. The database character set is UTF8.
    I have MySQL 5.07 installed on linux with one database. The database charset is UTF8. I needed a database link, so I installed MySQL ODBC driver where the Oracle is running.( I installed 5.1.6 64 bit version) I created datasource and configured everything on oracle. ( Database Gateway, Listener, dblink).
    Here comes what is strange for me:
    If I set HS_LANGUAGE=american_america.utf8 in the Database Gateway configuration, I get "ORA-00001: unique constraint violated" error after any singe select.( for example: select * from test_table@MYSQLDB ).
    If I set HS_LANGUAGE=american_america.we8mswin1252 or american_america.WE8ISO8859P15 everything seems fine, except special characters. If I try to insert for example cyrillic characters to mysql database the result become like this ???????.
    Did I do something wrong?
    Is there any workaround?

    Hi,
    This forum is for Oracle ODBC Driver issues. You'll most likely want to post your question in the Heterogeneous Services forum:
    Heterogeneous Connectivity
    Greg

  • MySQL password and root problems.......please help

    I've been trying to install and configure my computer to run MySQL. I've installed it and when I tried to change the password in the Terminal window by using: sudo /usr/local/mysql/bin/mysql -u root mysql
    I got an error message saying: ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
    I don't know what's happened and how I can change it.
    Thanks
    Lucy

    Lucy
    Since it is likely this error is generated by MySQL rather than OS X, you'd be better off posting your question in the UNIX forum, where a few MySQL users hang out.

  • Query, subquery problem??.. SOS...

    I've some trouble with this:
    I've got 4 tables
    LIVE
    id
    name
    street
    city
    WORK
    id
    comp_id
    sal
    LOCATED_IN
    com_id
    name
    city
    financial_group
    SUPERVISE
    id
    supervisor_id
    now, the problem:
    Lets say an XYZ financial group has companies located in different cities. I need to get all the companies from all others financial groups that have companies on all the cities where XYZ is present, For example if XYZ is present in LA, NY and SF, I need to get all the financial groups that have companies on all these cities as well even if they had companies in others citites besides these 3.
    i've tried many ways but couldnt get to it yet. Appreciate any help. THANKS!!!!!

    yeah matching up the column names... so it would be
    LIVE
    id (pk)
    name
    street
    city (fk)
    WORK
    id (pk)(fk)
    comp_id (fk)
    sal
    LOCATED_IN
    comp_id (pk)(fk)
    name
    city (fk)
    financial_group
    SUPERVISE
    id (pk)(fk)
    supervisor_id

  • Scalar Correlated Subquery Problem

    SELECT a.unit_id
    , NVL((
    SELECT COUNT(*)
    FROM (
    SELECT b.unit_id
    , b.rfq_id
    , b.vendor_id
    FROM RFQ_DISPATCHED b
    WHERE b.unit_id a.unit_id
    AND b.vendor_id = a.vendor_id
    AND b.rfq_id = a.rfq_id
    GROUP BY a.business_unit, a.rfq_id, a.vendor_id)),0) AS bid_qty
    FROM rfq_disp_hdr a
    WHERE a.unit_id = '00021'
    Oracle won't let me do this. Is it because it's correlated to a Query View? I know I can just create a view as a work around and then do a select on the view but any other suggestions on how to handle it?
    Thanks all!!

    Hi,
    Damorgan is right; whenever you have a question, you should post:
    (1) The version of Oracle (and any other relevant software) you're using
    (2) A little sample data (just enough to show what the problem is) from all the relevant tables
    (3) The results you want from that data, and an explanation of how you get from the data to the results
    (4) Your best attempt so far (formatted) (You posted this, but since it's unformated, it's very hard to read.)
    (5) The full error message (if any), including line number
    Executable SQL statements (like "CREATE TABLE AS ..." or "INSERT ..." statements) are best for (2).
    If you can present your problem using commonly available tables (for example, tables in scott schema, or views in the data dictionary), then you can omit (2).
    Formatted tabular output is okay for (3). Type these 6 characters:
    &#123;code&#125;
    (small letters only, inside curly brackets) before and after formatted text, to preserve spacing.
    You've been using this forum longer than I have; you should know this by now.
    It looks like the immediate problem is that you're trying to correlate a sub-query to its grandparent, not its parent. That is, the scalar sub-query could be correlated to the main query (its parent), and the in-line view could be corellated to the scalar sub-query (its parent), but the in-line view can not be correlated to the main query.
    Why are you using an in-line view? It looks like what you're trying to do is:
    SELECT      a.unit_id
    ,      NVL ( (
              SELECT        COUNT(*)
              FROM        RFQ_DISPATCHED b
              WHERE        b.unit_id a.unit_id
              AND        b.vendor_id     = a.vendor_id
              AND        b.rfq_id      = a.rfq_id
              GROUP BY  a.business_unit
              ,       a.rfq_id
              ,       a.vendor_id
             , 0
             ) AS bid_qty
    FROM      rfq_disp_hdr      a
    WHERE      a.unit_id      = '00021'but I think if correct this error, you'll just get another one. GROUPing by correlated values is very suspicious. So is doing a GROUP BY in a scalar sub-query like you're doing.
    If you really want to solve this problem, you'll have to post the information requested.

Maybe you are looking for