Global Connection String

Is there any way to use a global connection string variable for mysql database.
Currently there are some servlets in my web project.say ,
Servlet_1
Servlet_2
Servlet_3
Now i have to add these lines for each and every servlet to connect with mysql.
String driver =  "org.gjt.mm.mysql.Driver";
String url= "jdbc:mysql://localhost/my_db?user=root&password=dba";apart from that if there is a way to create a global connection string servlet or class i can reuse it with my application.
please let me know how to do this.

Ok this my Class for connection string.
package org.me.AuthAdmin;
public class ConString
    public ConString()
         String driver =  "org.gjt.mm.mysql.Driver";
          String url= "jdbc:mysql://localhost/my_db?user=root&password=dba"; 
}Please help me on this. i really don't know what to do here after.
package org.me.AuthAdmin;
import java.io.*;
import java.net.*;
import java.sql.*;
import javax.servlet.*;
import javax.servlet.http.*;
import org.me.AuthAdmin.ConString;
public class AuthAdmin extends HttpServlet
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException
                String postUserName = request.getParameter("txt_un").trim();
          String postUserPwd = request.getParameter("txt_pwd").trim();
                String db_user_name=null;
                String db_user_pwd=null;
        try
            //String driver =  "org.gjt.mm.mysql.Driver";
           // String url= "jdbc:mysql://localhost/my_db?user=root&password=dba";
            Class.forName(driver).newInstance();
            Connection con=DriverManager.getConnection(url);
            Statement stmt=con.createStatement();
            String qStr="SELECT * FROM sysusers WHERE user_name = '"+postUserName+"' AND user_pwd = '"+postUserPwd+"'";
            ResultSet rst=stmt.executeQuery(qStr);
            while(rst.next())
                db_user_name = rst.getString("user_name");
                db_user_pwd = rst.getString("user_pwd");     
        catch(Exception e)
            throw new ServletException(e);
       if( (postUserName.equals(db_user_name)) && (postUserPwd.equals(db_user_pwd)))
            response.sendRedirect("panel.jsp");
       }else
            response.sendRedirect("error.jsp");
}

Similar Messages

  • Connection String not in

    Hello:
       I have a strange problem. I have an addon that using single sign on to connect to UI and DI together. I uses the connstring = System.Convert.ToString(Environment.GetCommandLineArgs().GetValue(1)); to get the connection string from UI. I can do it from Release mode(and it's not the debugging connection string, it's the real application connection string. But can't do it with the .exe inside the release fold. keeping getting the out or array index exception, which means that line didn't grab the connection string from UI (my SBO is on)Is this normal? Here's the details
       I am using SBO 2005A(6.80.317) SP: 01 PL: 04. UI-API I am using is version: 6.8.0.0. DI-API I am using is 2005.0.0.0.
       I am keep on thinking that it might be the wrong UI that I am using, but the fact that it connect to it in the release mode means it should be ok! So what's my problem? Thank You!
    Here's my entire code:
    private void setapplication()
                   // connect to SBO GUI application
                string connstring = string.Empty;
                   SAPbouiCOM.SboGuiApi sboapi = new SAPbouiCOM.SboGuiApiClass();
                try
                    connstring = System.Convert.ToString(Environment.GetCommandLineArgs().GetValue(1));
                    MessageBox.Show(connstring);
                catch
                    MessageBox.Show("No connection String");
                    System.Environment.Exit(0);
                   try
                        sboapi.Connect(connstring);
                   catch(Exception ex)
                        MessageBox.Show(ex.Message);
                        System.Environment.Exit(0);
                   global.oapplicaiton = sboapi.GetApplication(-1);
    Message was edited by: Bo Peng

    Hi Bo,
    If you just start the exe by itself, you have to supply the connectionstring yourself.
    If the exe is started as an addon by SBO the connection string is supplied by SBO.
    regard
    Ad

  • Newbie question for LogOn trigger and Connection String

    Hi,
    I would like to set certain session variables in the logon trigger. Is there a connection string attribute or some other way to pass a string or some data to the session.
    regards
    Stefan

    Hi,
    my concrete problem is that our application only uses one user. eg. appuser . During the login process of the application the "real" user name, language and other attributes are set in a packag as global variables.
    This works fine, but as soon as a usr logs on the DB without our application login then these are ofcourse not filled. My idea was to maybe to be able to enhance the connection string and to be able to pass some more information to the logon trigger.
    regards
    Stefan

  • Global Connection Pool?

    Hello,
    Maybe this is not a specific OCCI question, sorry if this is not the best place to post this.
    Well, the point is I wanted please an opinion on witch is the best way to optimize (ie, limit the number of) the connections to the server in the following scenario: we have one database, multiple (in the order of hundreds) of clients that use many different applications and keep them open for most of the time (and in fact this is the problem, there are too many connections...);
    Most of the applications use the same business-logic component, that makes the connection to the database. I wanted to implement something like a timeout for the idle connections, but Ithink that disconnecting/reconnecting all the time would be slow. Then I came to the topic of a connection pool, but from what I understood a connection pool applies to only one process, right? What I wanted to achieve is something like a "global" connection pool, since all applications use the same component to access the data it just this component needs to be altered.
    My idea was then this: create another component (exe) that maintains a connection pool that is shared by many applictions (sure, I would write this in COM/ATL and it has to be a free threaded component); Then when some application needs to query for some data it simply instantiates a connection, uses it and releases it. The only real "operations" we need is query and update/insert of data, so it wouldn't be so difficult to implement a connection and a resultset objetct. Sure, we in this case there would be a constant communication between both applications (via COM), maybe it would slow it down a bit but since our applications are not so "real-time" and the bottleneck resides more in the server I thnk this wouldn't be an issue...
    My question is: is this a good idea, is it insane, or there exists another easier-better way to optimize our scenario, ie, reduce the number of connections used by multiple processes?
    Thanks,
    Tiago Gehring

    Hi everbright,
    I prefer NOT to make a JDBC connection pool a global resource. After all, if you have several applications on the same Tomcat instance you might not want them all to hit the same database. Better to make it a context-specific thing.
    I don't edit the server.xml - ever. I create the context XML in a separate file and deploy it with my WAR file. Tomcat picks it up automatically. Now my apps are nice and self-contained, and I don't have to ask a server admin to modify anything.
    Got the DBCP JAR in your WEB-INF/lib?
    This URL looks incorrect to me if you're using the Oracle JDBC driver:
    jdbc:oracle:thin:[email protected]:1521:DEVI think it should be:
    jdbc:oracle:thin:@127.0.0.1:1521:DEVLooks like you're trying to do this in a JSP. Have you tried moving the database code out of the JSP and into a JavaBean, where it belongs? You can test the database connection offline that way. Get it working and then worry about Tomcat.
    When I do a JNDI lookup, the Java code looks like this:
        /** Default JNDI lookup name for all data sources */
        public static final String DEFAULT_LOOKUP    = "java:comp/env/jdbc/APIPrototype";
         * Create a DatabaseBroker
         * @param lookup for data source
         * @throws NamingException if the lookup fails
         * @throws SQLException if the connection fails
        public DatabaseBroker(String lookup) throws NamingException, SQLException
            Context context = new InitialContext();
            DataSource ds   = (DataSource)context.lookup(lookup);
            this.connection = ds.getConnection();
            context.close();
        }I know this works, because it's been running in production under Tomcat 4.1.30 connecting to Oracle 9i for over a year.
    You can do this.
    %

  • How should load sensitive connection strings

    ok so when i need to connect a swf to some sort of data
    source on the server be it XML, a .NET DLL, a CFC or what ever so
    that i can load data from a database or what ever, everyone is
    always saying that i shouldn't hard code the connection string into
    my actionscript as anyone can get it and do malicious things with
    it.
    So how should i load the connection string into flash. if i
    put them on the server in an XML file or somthing like that then i
    still need to put a connection string into the actionscript in
    order to load in my main connection strings into the actionscript.
    Basically i need to know how to load an external string into
    a swf without anyone else being able to get hold of that string for
    them selves.
    i realy need help with this because i am developing an app
    for somone and i need it to connect to a database and i need it to
    be secure. i have everything sorted except making the connection
    string to the database unstealable.

    Hi
    1. The "GLOBAL.ASA" in ASP3 become "GLOBAL.ASAX" on ASP.Net and it is not the equivalent of web.config. ASP3 do not have an equivalent as this is dynamic tech and By default there is no precompile/compile action as in Dot.Net
     2. You can just move a text file which include the connection string outside the site's folder as we used to do 15 years ago when we used Microsoft Access as a database (When we need small database, before the SQL EXPRESS). This way there is no direct
    URL to get to file!
    * There are several option of restrict the use of a file in ASP3 and in the IIS configuration. check if this is what you want (restrict the use of a specific file/folder) 
    3. robot.txt is only for searching engine which keep "nice behavior". it do not stop any application including search engine from getting the file.
    Have fun :-)
    [Personal Site] [Blog] [Facebook]

  • Query engine : Can not find DSN in Connection String

    DearSir/Madam,
    Opearating System Windows 7 Professional(32-bit).
    I am using Application, which is developed : Visual basic 6.0(32-bit), Report Writer : Crystal Report 9.2.693(32-bit) and database: Oracle 9.2.0.10(32-bit).
    ODBC Data source : System DSN created and Connection established (Based on Driver : CR ORACLE ODBC Driver 4.10 (cror818.dll))
    In windows 7 environment Data Base connectivity and data fetching also wroking fine.
    My problem is while running reports it display error as "Query engine : Can not find DSN in Connection String"
    I want run time reports.
    For your kind information, at the same time in Windows XP Professional there is no problem found and working fine.
    Kindly help me.
    Thanks and regards,
    Swarup

    Crystal Reports 9.x is not supported on Win 7. See the following wiki:
    http://wiki.sdn.sap.com/wiki/x/b4JiAw
    - Ludek

  • How to specifiy the provider to be Oracle.ManagedDataAccess.Client when creating a dynamic connection string with EF Code First from Database?

    I am trying to use the relatively new Code First from Database with the newest EF (6.x) and on an Oracle database (11g, but I have installed the newest ODTwithODAC). First of all, it works fine as long as the connection string is inside the App.Config file. But when I try to build it dynamically in the C# code (or rather, statically at the moment) it fails. I have it working with a dynamically built connection string when doing Model from Database though, so I'm at a loss right now.
    First, I have created a second constructor for the context class that takes a string and does base(connectionString). Then I build the connection string via
    OracleConnectionStringBuilder oracleBuilder = new OracleConnectionStringBuilder();
    oracleBuilder.DataSource = "TEST.BLA.COM";
    oracleBuilder.UserID = "ABC";
    oracleBuilder.Password = "abc";
    oracleBuilder.PersistSecurityInfo = true;
    string connection = oracleBuilder.ToStrin();
    Now trying to open an EntityConnection by giving to it this provider-specific connection string (or even the static one from the App.Config) doesn't work; I get "keyword not supported: user id"). Trying it by creating a context and giving this connection string doesn't work either. I'm pretty sure that this is because I didn't specify the provider to use; after all, it should use the Oracle.ManagedDataAccess.Client provider and not an SQL Server based one.
    I then tried to get around this by using an EntityConnectionStringBuilder on top and specifying the provider keyword there, but then I get "keyword not supported: provider" when using it in the context constructor, and "the 'metadata' keyword is always required" when using it with the EntityConnection constructor.
    As I said above: I bet it's the provider that I have to specify somehow, but I don't know how. The code that does work is the following:
    using (var context = new Model())
    context.Database.Connection.Open();
    context.Database.Connection.Close();
    When I read context.Database.Connection.ConnectionString, it is exactly the provider-specific connection string I created above, but I don't know where to specify the provider again. Do you know of any way to do this? Certainly there must be one.
    PS: I have also posted this question on http://stackoverflow.com/questions/27979454/ef-code-first-from-database-with-managed-oracle-data-access-dynamic-connection because it is quite urgent and I'd like to use Code First from Database. Otherwise I'd have to go "back" to using Model from Database again, which is not ideal because we have updatable views where the .edmx-file has to be edited after every reload of the model, while with Code First from DB inserting into the view automatically works.

    I am trying to use the relatively new Code First from Database with the newest EF (6.x) and on an Oracle database (11g, but I have installed the newest ODTwithODAC). First of all, it works fine as long as the connection string is inside the App.Config file. But when I try to build it dynamically in the C# code (or rather, statically at the moment) it fails. I have it working with a dynamically built connection string when doing Model from Database though, so I'm at a loss right now.
    First, I have created a second constructor for the context class that takes a string and does base(connectionString). Then I build the connection string via
    OracleConnectionStringBuilder oracleBuilder = new OracleConnectionStringBuilder();
    oracleBuilder.DataSource = "TEST.BLA.COM";
    oracleBuilder.UserID = "ABC";
    oracleBuilder.Password = "abc";
    oracleBuilder.PersistSecurityInfo = true;
    string connection = oracleBuilder.ToStrin();
    Now trying to open an EntityConnection by giving to it this provider-specific connection string (or even the static one from the App.Config) doesn't work; I get "keyword not supported: user id"). Trying it by creating a context and giving this connection string doesn't work either. I'm pretty sure that this is because I didn't specify the provider to use; after all, it should use the Oracle.ManagedDataAccess.Client provider and not an SQL Server based one.
    I then tried to get around this by using an EntityConnectionStringBuilder on top and specifying the provider keyword there, but then I get "keyword not supported: provider" when using it in the context constructor, and "the 'metadata' keyword is always required" when using it with the EntityConnection constructor.
    As I said above: I bet it's the provider that I have to specify somehow, but I don't know how. The code that does work is the following:
    using (var context = new Model())
    context.Database.Connection.Open();
    context.Database.Connection.Close();
    When I read context.Database.Connection.ConnectionString, it is exactly the provider-specific connection string I created above, but I don't know where to specify the provider again. Do you know of any way to do this? Certainly there must be one.
    PS: I have also posted this question on http://stackoverflow.com/questions/27979454/ef-code-first-from-database-with-managed-oracle-data-access-dynamic-connection because it is quite urgent and I'd like to use Code First from Database. Otherwise I'd have to go "back" to using Model from Database again, which is not ideal because we have updatable views where the .edmx-file has to be edited after every reload of the model, while with Code First from DB inserting into the view automatically works.

  • How to dynamically set connection string for report in C# code?

    Hi,
    I have installed CRVS2010. I have created new Crystal Report WPF Application and new report. I would like to set connection string for report in code dynamically.
    Is this possible?
    Thanks
    Ivana

    Lots of posts in this forum on how to set database connections. WPF should not be a consideration as it's just a viewer. The report engine is still the same. Search these forums. Use the search box at the top right corner of this page. Look at samples here:
    https://wiki.sdn.sap.com/wiki/display/BOBJ/CrystalReportsfor.NETSDK+Samples
    Note that none of the samples above are using WPF, but like I said, the WPF is just a different viewer and will not impact how the report engine logs on to a database. (I think of it as a gray car vs. a red car. Same engine, just the color is different)
    Ludek
    Follow us on Twitter http://twitter.com/SAPCRNetSup
    Got Enhancement ideas? Try the [SAP Idea Place|https://ideas.sap.com/community/products_and_solutions/crystalreports]

  • Deployment from 11g to 10g connection string cannot get provider error.

    Hi, I'm doing a deployment from oracle client 11g to 10g. Is this possible? there are yes and no answer I have try out from the forum. All did not workout with any of the configuration setup.
    For development I am using VS2012, MVC 4. EF 4. Oracle 11g
    The server is currently running Oracle 10g with Oracle.Dataaccess.dll 10.2.0.100
    This is my connection string setup at the server.
    <?xml version="1.0"?>
    <!--
    For more information on how to configure your ASP.NET application, please visit
    http://go.microsoft.com/fwlink/?LinkId=169433
    -->
    <configuration>
    <configSections>
    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=4.4.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"/>
    </configSections>
    <connectionStrings>
    <add name="OraAspNetConnectionString" connectionString="Data Source=dtsr;User Id=ids;Password=pwd;" providerName="Oracle.DataAccess.Client"/>
    <add name="OraAspNetConnectionString2" connectionString="Data Source=dtsr;User Id=ids;Password=pwd;" providerName="Oracle.DataAccess.Client.OracleConnection"/>
    </connectionStrings>
    <!--<startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0" />
    </startup>-->
    <appSettings>
    <add key="webpages:Version" value="2.0.0.0"/>
    <add key="webpages:Enabled" value="false"/>
    <add key="PreserveLoginUrl" value="true"/>
    <add key="ClientValidationEnabled" value="true"/>
    <add key="UnobtrusiveJavaScriptEnabled" value="true"/>
    </appSettings>
    <system.data>
    <DbProviderFactories>
         <add name="Oracle Data Provider for .NET" invariant="Oracle.DataAccess.Client" description="Oracle Data Provider for .NET" type="Oracle.DataAccess.Client.OracleClientFactory,Oracle.DataAccess,Version=4.112.3.0,Culture=neutral,PublicKeyToken=89b483f429c47342" />
    </DbProviderFactories>
    </system.data>
    <system.web>
    <compilation targetFramework="4.0">
    <assemblies>
    <add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
    <add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
    <add assembly="System.Web.Helpers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
    <add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
    <add assembly="System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
    <add assembly="System.Web.WebPages, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
    </assemblies>
    </compilation>
    <httpRuntime/>
    <authentication mode="Windows"/>
    <identity impersonate="true"/>
    <pages controlRenderingCompatibilityVersion="4.0">
    <namespaces>
    <add namespace="System.Web.Helpers"/>
    <add namespace="System.Web.Mvc"/>
    <add namespace="System.Web.Mvc.Ajax"/>
    <add namespace="System.Web.Mvc.Html"/>
    <add namespace="System.Web.Optimization"/>
    <add namespace="System.Web.Routing"/>
    <add namespace="System.Web.WebPages"/>
    </namespaces>
    </pages>
    <sessionState mode="InProc" timeout="20" cookieless="false"/>
    </system.web>
    <system.webServer>
    <validation validateIntegratedModeConfiguration="false"/>
    <handlers>
    <remove name="ExtensionlessUrlHandler-ISAPI-4.0_32bit"/>
    <remove name="ExtensionlessUrlHandler-ISAPI-4.0_64bit"/>
    <remove name="ExtensionlessUrlHandler-Integrated-4.0"/>
    <add name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness32" responseBufferLimit="0"/>
    <add name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness64" responseBufferLimit="0"/>
    <add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0"/>
    </handlers>
    <security>
    <authorization>
    <add accessType="Allow" users="?"/>
    </authorization>
    </security>
    </system.webServer>
    <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
    <dependentAssembly>
    <assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35"/>
    <bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0"/>
    </dependentAssembly>
    <dependentAssembly>
    <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35"/>
    <bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0"/>
    </dependentAssembly>
    <dependentAssembly>
    <assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35"/>
    <bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0"/>
    </dependentAssembly>
    <!--<dependentAssembly>
    <assemblyIdentity name="Oracle.DataAccess, Version=10.2.0.100, Culture=Neutral," publicKeyToken="89b483f429c47342" />
    <bindingRedirect oldVersion="10.2.0.100" newVersion="4.112.3.0"/>
              <publisherPolicy apply="no" />
    </dependentAssembly>-->
    </assemblyBinding>
    </runtime>
    <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework"/>
    </entityFramework>
    </configuration>
    I get this error when page trying to connect to database.
    [ProviderIncompatibleException: An error occurred while getting provider information from the database. This can be caused by Entity Framework using an incorrect connection string. Check the inner exceptions for details and ensure that the connection string is correct.]
    System.Data.Entity.ModelConfiguration.Utilities.DbProviderServicesExtensions.GetProviderManifestTokenChecked(DbProviderServices providerServices, DbConnection connection) +163
    System.Data.Entity.ModelConfiguration.Utilities.DbConnectionExtensions.GetProviderInfo(DbConnection connection, DbProviderManifest& providerManifest) +39
    System.Data.Entity.DbModelBuilder.Build(DbConnection providerConnection) +46
    System.Data.Entity.Internal.LazyInternalContext.CreateModel(LazyInternalContext internalContext) +62
    System.Data.Entity.Internal.RetryLazy`2.GetValue(TInput input) +117
    System.Data.Entity.Internal.LazyInternalContext.InitializeContext() +453
    System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(Type entityType) +18
    System.Data.Entity.Internal.Linq.InternalSet`1.Initialize() +56
    System.Data.Entity.Internal.Linq.InternalSet`1.get_InternalContext() +15
    System.Data.Entity.Infrastructure.DbQuery`1.System.Linq.IQueryable.get_Provider() +37
    I have check the
    1. Enviroment Variables path is set to the 10.../client_1/
    2. Tnsname.ora already configured.
    3. machine.config did not define the connection string path, as it is define in the web.config
    4. Oracle.Dataaccess.dll is in the bin of my application website (v4.112.3.0).
    5. In my application web bin folder also include additional dlll.
    mfc71.dll
    msvcr71.dll
    oci.dll
    ociw32.dll
    orannzsbb11.dll
    oraocci11.dll
    oraociicus11.dll
    OraOps11w.dll
    Anyone please help.. Thanks in advance..
    Edited by: 976886 on Dec 13, 2012 7:46 PM

    976886 wrote:
    I want to know, it is possible to migrate the application from oracle 11g to 10g? such that the component are supported across?
    Because in the development, all goes well, no error on the oracle connection.
    OR did I miss out anything that causes it not working on my server deployment?yes
    yes
    yes
    how can we reproduce what you claim?

  • I run Dev 6i on Windows 2008 R2 64-bit,the forms are working fine after connection to the database but the reports continue to request for username, password and database connection string every time i try to open a report.

    I receive REP-0501: Unable to connect to specified database. I run developer 6i application on windows 2008 r2. I have applied the nn60.dll and nnb60.dll files to the \BIN directory. The forms are working fine. The reports will only display after the correct user id (username, password and database connection string) is supplied. This is happening to all attempts to open already complied form. Pls, help.

    If you are connecting to an Oracle 11g database, remember that by default the passwords are case sensitive. To disable that, run
    ALTER SYSTEM SET SEC_CASE_SENSITIVE_LOGON = FALSE;

  • Powershell use Connection String to query Database and write to Excel

    Right now I have a powershell script that uses ODBC to query SQL Server 2008 / 2012 database and write to EXCEL
    $excel = New-Object -Com Excel.Application
    $excel.Visible = $True
    $wb = $Excel.Workbooks.Add()
    $ws = $wb.Worksheets.Item(1)
    $ws.name = "GUP Download Activity"
    $qt = $ws.QueryTables.Add("ODBC;DSN=$DSN;UID=$username;PWD=$password", $ws.Range("A1"), $SQL_Statement)
    if ($qt.Refresh()){
    $ws.Activate()
    $ws.Select()
    $excel.Rows.Item(1).HorizontalAlignment = $xlCenter
    $excel.Rows.Item(1).VerticalAlignment = $xlTop
    $excel.Rows.Item("1:1").Font.Name = "Calibri"
    $excel.Rows.Item("1:1").Font.Size = 11
    $excel.Rows.Item("1:1").Font.Bold = $true
    $filename = "D:\Script\Reports\Status_$a.xlsx"
    if (test-path $filename ) { rm $filename }
    $wb.SaveAs($filename, $xlOpenXMLWorkbook) #save as an XML Workbook (xslx)
    $wb.Saved = $True #flag it as being saved
    $wb.Close() #close the document
    $Excel.Quit() #and the instance of Excel
    $wb = $Null #set all variables that point to Excel objects to null
    $ws = $Null #makes sure Excel deflates
    $Excel=$Null #let the air out
    I would like to use connection string to query the database and write results to EXCEL, i.e.
    $SQL_Statement = "SELECT ..."
    $conn = New-Object System.Data.SqlClient.SqlConnection
    $conn.ConnectionString = "Server=10.10.10.10;Initial Catalog=mydatabase;User Id=$username;Password=$password;"
    $conn.Open()
    $cmd = New-Object System.Data.SqlClient.SqlCommand($SQL_Statement,$conn)
    do{
    try{
    $rdr = $cmd.ExecuteReader()
    while ($rdr.read()){
    $sql_output += ,@($rdr.GetValue(0), $rdr.GetValue(1))
    $transactionComplete = $true
    catch{
    $transactionComplete = $false
    }until ($transactionComplete)
    $conn.Close()
    How would I read the columns and data for $sql_output into an EXCEL worksheet. Where do I find these tutorials?

    Hi Q.P.Waverly,
    If you mean to export the data in $sql_output to excel document, please try to format the output with psobject:
    $sql_output=@()
    do{
    try{
    $rdr = $cmd.ExecuteReader()
    while ($rdr.read()){
    $sql_output+=New-Object PSObject -Property @{data1 = $rdr.GetValue(0);data2 =$rdr.GetValue(1)}
    $transactionComplete = $true
    catch{
    $transactionComplete = $false
    }until ($transactionComplete)
    $conn.Close()
    Then please try to use the cmdlet "Export-Csv" to export the data to excel like:
    $sql_output | Export-Csv d:\data.csv
    Or you can export to worksheet like:
    $excel = New-Object -ComObject Excel.Application
    $excel.Visible = $true
    $workbook = $excel.Workbooks.Add()
    $sheet = $workbook.ActiveSheet
    $counter = 0
    $sql_output | ForEach-Object {
    $counter++
    $sheet.cells.Item($counter,1) = $_.data1$sheet.cells.Item($counter,2) = $_.data2}
    Refer to:
    PowerShell and Excel: Fast, Safe, and Reliable
    If there is anything else regarding this issue, please feel free to post back.
    Best Regards,
    Anna Wang

  • How do I create a connection string to sql server?

    Hi All,
       I am currently connecting to a SQL Server via ODBC DSN connection. I am wondering how do I create a connection string directly to a sql server without a DSN connection?
    Thank you in advance.

    If you have SQL Server or client installed in your machine you can directly connect to SQL server using native connection. When you create new report you can see the option create new connection, here you can see SQL Server. Expand it and enter the connection details where you will be directly connected to SQL Server without ODBC connection.
    Regards,
    Raghavendra

  • Changing Connection String dynamically at runtime

    I am using the Crystal Report Viewer control in in a Visuall Studio 2008 C# project.  The reports are created inside of Visual Studio 2008, and will be running against an InterSystems Cache database.  I have to use an ODBC (RDO) connection and use a connection string.
    I have seen many examples of how to update the connection string at runtime if it is SQL server (or some flavor thereof), but nothing for an ODBC (RDO) connection to a NON-MSSQL database.
    The problem when I update the connection string for each of the tables in the report, the report will either not run and display a window -- tiled 'Datbase Login' -- that has the Server, Database, Username, and Password fields on the window, OR, it will run but not against the database that was specified at runtime (it uses the connection stored in the report).
    Code Sample #1 (This is using the connection string, and will cause a the "Database Login" window to be displayed - the first scenario from above)
    rd = new ReportDocument();
    // Load the report
    rd.Load(fileName, OpenReportMethod.OpenReportByDefault);
    rd.Refresh();
    // Create the connection object
    ConnectionInfo connectionInfo = CreateConnection(Server, Port, ServerNamespace, Username, Password);
    // Set the connection info on each table in the report
    SetDBLogonForReport(connectionInfo, rd);
    SetDBLogonForSubreports(connectionInfo, rd);
    private static ConnectionInfo CreateConnection(string Server,
                                                   int Port,
                                                   string ServerNamespace,
                                                   string Username,
                                                   string Password)
            ConnectionInfo connectionInfo = new ConnectionInfo();
            string connString = "DRIVER=InterSystems ODBC;SERVER=" + Server
                                                      + ";PORT=" + Port
                                                      + ";DATABASE=" + ServerNamespace
                                                      + ";UID=" + Username
                                                      + ";PWD=" + Password;
            connectionInfo.IntegratedSecurity = false;
            connectionInfo.UserID = Username;
            connectionInfo.Password = Password;        //In examples that I have seen, this is the actual connection string, not just the server name
            connectionInfo.ServerName = connString;          connectionInfo.DatabaseName = ServerNamespace;
            connectionInfo.Type = ConnectionInfoType.CRQE;
            return connectionInfo;
    private static void SetDBLogonForReport(ConnectionInfo connectionInfo, ReportDocument reportDocument)
            foreach (CrystalDecisions.CrystalReports.Engine.Table table in reportDocument.Database.Tables)
                TableLogOnInfo tableLogonInfo = table.LogOnInfo;
                tableLogonInfo.ConnectionInfo = connectionInfo;
                table.ApplyLogOnInfo(tableLogonInfo);
    private static void SetDBLogonForSubreports(ConnectionInfo connectionInfo, ReportDocument reportDocument)
            foreach (Section section in reportDocument.ReportDefinition.Sections)
                foreach (ReportObject reportObject in section.ReportObjects)
                    if (reportObject.Kind == ReportObjectKind.SubreportObject)
                        SubreportObject subreportObject = (SubreportObject)reportObject;
                        ReportDocument subReportDocument = subreportObject.OpenSubreport(subreportObject.SubreportName);
                        SetDBLogonForReport(connectionInfo, subReportDocument);
    Sample #2 (the same as Sample #1 above, only the ConnectionInfo method is different - which is all that I included here)
    private static ConnectionInfo CreateConnection(string Server,
                                                    int Port,
                                                   string ServerNamespace,
                                                   string Username,
                                                   string Password)
            ConnectionInfo connectionInfo = new ConnectionInfo();
            string connString = "DRIVER=InterSystems ODBC;SERVER=" + Server
                                                      + ";PORT=" + Port
                                                      + ";DATABASE=" + ServerNamespace
                                                      + ";UID=" + Username
                                                      + ";PWD=" + Password;
            connectionInfo.Attributes.Collection.Add(new NameValuePair2(
                              DbConnectionAttributes.CONNINFO_DATABASE_DLL, DbConnectionAttributes.DATABASE_DLL_CRDB_ODBC));
            connectionInfo.Attributes.Collection.Add(new NameValuePair2(
                              DbConnectionAttributes.QE_DATABASE_NAME, ServerNamespace));
            connectionInfo.Attributes.Collection.Add(new NameValuePair2(
                              "QE_DatabaseType", "ODBC (RDO)"));
            DbConnectionAttributes attributes = new DbConnectionAttributes();
            attributes.Collection.Add(new NameValuePair2(
                              DbConnectionAttributes.CONNINFO_CONNECTION_STRING, connString));
            attributes.Collection.Add(new NameValuePair2(
                              "Server", Server));
            attributes.Collection.Add(new NameValuePair2(
                              "UseDSNProperties", false));
            connectionInfo.Attributes.Collection.Add(new NameValuePair2
    (                          DbConnectionAttributes.QE_LOGON_PROPERTIES, attributes));
            connectionInfo.Attributes.Collection.Add(new NameValuePair2(
                              DbConnectionAttributes.QE_SERVER_DESCRIPTION, Server));
            connectionInfo.Attributes.Collection.Add(new NameValuePair2(
                              "QE_SQLDB", true));
            connectionInfo.Attributes.Collection.Add(new NameValuePair2(
                              DbConnectionAttributes.CONNINFO_SSO_ENABLED, false));
            connectionInfo.IntegratedSecurity = false;
            connectionInfo.UserID = Username;
            connectionInfo.Password = Password;
            connectionInfo.ServerName = connString;
            connectionInfo.DatabaseName = ServerNamespace;
            connectionInfo.Type = ConnectionInfoType.CRQE;
            return connectionInfo;
    I have also tried setting connectionInfo.ServerName equal to just the real server name, but that didn't work either.
    After the above operations are performed, I simply assign the returned ReportDocument object to the Crystal Viewer control.  If I don't call the above functions, and just set the ReportDocument source (using whatever connection string was embedded in the report originally), the report runs as expected.  Only when I attempt to update the connection string, the report will not execute.  Please advise.  Thanks!

    I am using the Crystal Report Viewer control in in a Visuall Studio 2008 C# project.  The reports are created inside of Visual Studio 2008, and will be running against an InterSystems Cache database.  I have to use an ODBC (RDO) connection and use a connection string.
    I have seen many examples of how to update the connection string at runtime if it is SQL server (or some flavor thereof), but nothing for an ODBC (RDO) connection to a NON-MSSQL database.
    The problem when I update the connection string for each of the tables in the report, the report will either not run and display a window -- titled 'Datbase Login' -- that has the Server, Database, Username, and Password fields on the window, OR, it will run but not against the database that was specified at runtime (it uses the connection stored in the report).
    Code Sample #1 (This is using the connection string, and will cause a the "Database Login" window to be displayed - the first scenario from above) -- The code samples appear to be too long to post, so I will add them as seperate replies.
    rd = new ReportDocument();
    // Load the report
    rd.Load(fileName, OpenReportMethod.OpenReportByDefault);
    rd.Refresh();
    // Create the connection object
    ConnectionInfo connectionInfo = CreateConnection(Server, Port, ServerNamespace, Username, Password);
    // Set the connection info on each table in the report
    SetDBLogonForReport(connectionInfo, rd);
    SetDBLogonForSubreports(connectionInfo, rd);
    private static ConnectionInfo CreateConnection(string Server, int Port, string ServerNamespace, string Username, string Password)
            ConnectionInfo connectionInfo = new ConnectionInfo();
            string connString = "DRIVER=InterSystems ODBC;SERVER=" + Server + ";PORT=" + Port + ";DATABASE=" + ServerNamespace + ";UID=" + Username + ";PWD=" + Password;
            connectionInfo.IntegratedSecurity = false;
            connectionInfo.UserID = Username;
            connectionInfo.Password = Password;        //In examples that I have seen, this is the actual connection string, not just the server name
            connectionInfo.ServerName = connString;          connectionInfo.DatabaseName = ServerNamespace;
            connectionInfo.Type = ConnectionInfoType.CRQE;
            return connectionInfo;
    // Code smple continued in the next reply

  • Problem with Connection Manager. Can't change connection string / Server name

    p.MsoNormal, li.MsoNormal, div.MsoNormal
    {margin-top:0cm;margin-right:0cm;margin-bottom:10.0pt;margin-left:0cm;line-height:115%;font-size:11.0pt;font-family:'Calibri','sans-serif';}
    .MsoChpDefault
    {font-size:10.0pt;}
    .MsoPapDefault
    {line-height:115%;}
    @page Section1
    {size:612.0pt 792.0pt;margin:72.0pt 72.0pt 72.0pt 72.0pt;}
    div.Section1
    {page:Section1;}
    Hi,
    I have copied a number of SSID packages from a live server to my test server and am trying to get them up and running but I have a problem with the connection. The only thing that is different is the server name. I decided to keep the same connection in the connection manager as it is referenced in a dtsConfig file. I changed the dtsConfig file to reference the new servername [Data Source= new test server name]. I also check my paths and they are pointing to the correct config locations etc.
    I found this post which was similar to my problem but I still get problems with the connection
    http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1319961&SiteID=1
    I updated the connection by changing the server name in the actual connection. I did this from the data flow tab in the Connection Managers sections (MS Visual Studio). Right clicked - Edit - changed the name of the server name to my test server and selected the database. Test connection was fine, and saved this.
    Once I saved this, the connection string changed to my current test server in the properties of the connection. However when I run the package I get the following error:
    Error: 0xC0202009 at ReportsImport, Connection manager "myconnectionstring": SSIS Error Code DTS_E_OLEDBERROR.  An OLE DB error has occurred. Error code: 0x80004005.
    An OLE DB record is available.  Source: "Microsoft SQL Native Client"  Hresult: 0x80004005  Description: "Login timeout expired".
    An OLE DB record is available.  Source: "Microsoft SQL Native Client"  Hresult: 0x80004005  Description: "An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections.".
    An OLE DB record is available.  Source: "Microsoft SQL Native Client"  Hresult: 0x80004005  Description: "Named Pipes Provider: Could not open a connection to SQL Server [53]. ".
    Error: 0xC020801C at Myprocess import from file, BuyAtReportsImport [79]: SSIS Error Code DTS_E_CANNOTACQUIRECONNECTIONFROMCONNECTIONMANAGER.  The AcquireConnection method call to the connection manager "myconnectionstring" failed with error code 0xC0202009.  There may be error messages posted before this with more information on why the AcquireConnection method call failed.
    Error: 0xC0047017 at Myprocess import from file, DTS.Pipeline: component "ReportsImport" (79) failed validation and returned error code 0xC020801C.
    Error: 0xC004700C at Myprocess import from file, DTS.Pipeline: One or more component failed validation.
    Error: 0xC0024107 at Myprocess import from file: There were errors during task validation.
    So even if I change the existing connection properties and save and Build my package again, my connection properties (connectionstring, servername etc) all revert back to its original data source when I re-open the package. Simply it does not seem to be saving the connection properties i put in.
    What am I doing wrong or how can I change the existing connection manager to look at the new server. The database is  the same and I have full admin privilege on the server.
    I don't want to recreate my packages as there are alot and they are not simple.
    After changing the connection properties, saving and reloading I get a connection error. But this is because it is not retaining the new connection manger setting i entered.
    Incidentally - I created a new SSID to perform a simple connection and write to the the server and it was OK so there is no problem with actually seeing the my test server.
    Thanks in advance

    Yes, the package is in visual studio and I have executed it. There are no errors but in the output i have the error message about my connection. My dtsConfig file is added to the project in the 'Package Configuration Organizer' and path and files are correct. This is the output error:
    Error: 0xC020801C at xx import from file, xxReportsImport [79]: SSIS Error Code DTS_E_CANNOTACQUIRECONNECTIONFROMCONNECTIONMANAGER.  The AcquireConnection method call to the connection manager "myconnectionname" failed with error code 0xC0202009.  There may be error messages posted before this with more information on why the AcquireConnection method call failed.
    I will try and run it using dtexec.exe. if I have two config files do i use
    dtsexec.exe /f <packagename> /conf <configfile> /conf <secondconfigfile>

  • Connect String for the front end app to access Lite Database in the Client

    Hi,
    I have been using an app developed in VB.net for accessing the Oracle Lite Database from the client machine. Can anyone please help me out how to set the Connect String in the config file of my front end app to access the Oracle Lite Database from my client machine. Do anyone have the syntax of the connect string to access the lite database in client machine.
    Thanks a lot in advance.

    Hi...
    -->Select example
    create or replace procedure get_emp(rc out sys_refcursor)
    is
    begin
    open rc for select * from emp;
    end;
    -->DML example
    create or replace procedure do_dml_emp(pempid in number,
    pempname varchar2,
    result out number)
    is
    begin
    insert into emp(empid,empname) values(pempid,pempname) returning empid into result;
    exception
    when others then
    result:=-1;
    end;
    -->DDL example
    create or replace procedure ddl_emp(colname varchar2,
    coltype varchar2,
    result out number)
    is
    begin
    result:=-1;
    execute immediate 'alter table emp add column ' || colname || ' ' || coltype ;
    result:=1;
    end;

Maybe you are looking for

  • Looking for a W7 T500 Lenovo app/driver checklist.

    I have my T500 loaded with W7 PRO 64. It came with Vista Ultimate 32. I have a list of the drivers and apps that came with the Vista preload. Is there a list or cross reference some where that I can use to make sure I got all the pieces and parts of

  • When FMLE stopped,Remote RTMP stream to FMS 4.5 with rtmfp?

    When FMLE stopped,Remote RTMP stream to FMS 4.5 with rtmfp? edit  "applications/multicast/main.asc" ? HELP ME !!! THANKS!!! * File: main.asc * The server-side portion of the multicast sample application. * This app accepts publish and unpublish reque

  • Migrating  from Crystal Reports 9 to Crystal Reports XI

    Hi, I have a java web project that uses Crystal Reports 9 to generate reports. I need to make my project compatible with Crystal Reports XI. I researched and found that Crystal reports XI does not use a report Application server however it can use to

  • Can I print a pdf file from my phone?

    Can I print a pdf file from my phone

  • Primary Key Data type in Time Dimension????

    I have to create a Time dimension with day grain in a Datawarehouse system and I don’t know what is the best data type for the primary key... For example 1) I could put Number(8) datatype, then the dates will be: 20050114, 20050115, 20050116.... Th