Application that connects to multiple databases.
I am developing an application that performs many task, but one in particular is connecting to multiple databases and creating user accounts in each all with the push of a single button. I have tried putting connect statements in the trigger code but I don't get the desired results.
How would I get my application to switch database connections while in execution?
Please reply to the forum, or email me @ [email protected]
Thank you.
Travis
Hi
The only possible way which I could find for your requirement is that of DB Links. Establish DataBase Links among the multible databases, with which you want to work in one session. Peform all your actions through the DB Links.
Similar Messages
-
Best practise for creating an application that connects to a SQL Server database
I have created an application that connects to a SQL Server database and views information using a datagrid and performs several updates when a button
is selected.
I have created a SQLcontrol.vb using the following code:
Imports System.Data.Sql
Imports System.Data.SqlClient
Public Class SQlControl
'connection 1
Public SQLCon As New SqlConnection With {.ConnectionString
= "Data Source=;Initial Catalog=;Integrated Security=True"}
'connection 2
Public SQLCon1 As New SqlConnection With {.ConnectionString
= "Data Source;Initial Catalog=;Integrated Security=True"}
Public sqlcmd As SqlCommand
Public sqlda As SqlDataAdapter
Public sqldataset As DataSet
Public Function hasconnection() As Boolean
Try
SQLCon.open()
SQLCon.close()
Return True
Catch ex As Exception
MsgBox(ex.Message)
Return False
End Try
End Function
Public Sub runquery(query As String)
Try
SQLCon.Open()
sqlcmd = New SqlCommand(query,
SQLCon)
'LOAD
SQL RECORDS FOR DATAGROD
sqlda = New SqlDataAdapter(sqlcmd)
sqldataset = New DataSet
sqlda.Fill(sqldataset)
BH READ DIRECTLY FROM THE DATABASE
'Dim
R As SqlDataReader = sqlcmd.ExecuteReader
'While
R.Read
'MsgBox(R.GetName(0)
& ": " & R(0))
'End
While
SQLCon.Close()
Catch ex As Exception
MsgBox(ex.Message)
'will
close connection if still open
If SQLCon.State
= ConnectionState.Open Then
SQLCon.Close()
End If
End Try
End Sub
Public Sub runquery1(query As String)
Try
SQLCon1.Open()
sqlcmd = New SqlCommand(query,
SQLCon1)
'LOAD
SQL RECORDS FOR DATAGROD
sqlda = New SqlDataAdapter(sqlcmd)
sqldataset = New DataSet
sqlda.Fill(sqldataset)
BH READ DIRECTLY FROM THE DATABASE
'Dim
R As SqlDataReader = sqlcmd.ExecuteReader
'While
R.Read
'MsgBox(R.GetName(0)
& ": " & R(0))
'End
While
SQLCon1.Close()
Catch ex As Exception
MsgBox(ex.Message)
'will
close connection if still open
If SQLCon1.State
= ConnectionState.Open Then
SQLCon1.Close()
End If
End Try
End Sub
End Class
A code for one of my button which views displays data grid contains the following code:
Private Sub Button1_Click_1(sender As Object,
e As EventArgs) Handles Button1.Click
If SQL.hasconnection
= True Then
SQL.runquery("select
* from tablea")
If SQL.sqldataset.Tables.Count
> 0 Then
DGVData.DataSource = SQL.sqldataset.Tables(0)
End If
End If
End Sub
I am fairly new to vb.net and have read a few books and followed a few tutorials on youtube, what I would like to know is, are there any disadvantages
to the way I have connected to a SQL database using the SQLControl.vb. A lot of the vb books include data adapter and dataset within the form, I'm not sure if I'm following best practice by have the connection details outside of the form.
My other question is, I have created two connections in the SQLControl and call these connections within the same form using the same data adapter
and dataset. It all works fine but I just wanted to know of any potential issues?
Public SQLCon As New SqlConnection With {.ConnectionString
= "Data Source=;Initial Catalog=;Integrated Security=True"}
'connection 2
Public SQLCon1 As New SqlConnection With {.ConnectionString
= "Data Source;Initial Catalog=;Integrated Security=True"}
ThanksMy other question is, I have created two connections in the SQLControl and call these connections within the same form using the same data adapter and dataset. It all works fine but
I just wanted to know of any potential issues
1) You are not using Sepration of concerns for a solution that is doing data access, like using a DAL.
http://en.wikipedia.org/wiki/Separation_of_concerns
2) You are directly issuing SQL commands at the UI, leading to sql injection attacks.
3) You are not using a UI design pattern, which leads you to tightly couple database activity to the UI.
http://www.codeproject.com/Articles/228214/Understanding-Basics-of-UI-Design-Pattern-MVC-MVP
@System243trd, parameters are important to prevent SQL injection attacks (people will insert SQL commands into the database if you do not perform basic checking of what you are passing to the database). If you write a stored procedure try to make
the variables the correct SQL server data type to avoid problems later of people trying to call it directly. Darnold924 is right, I see no code to prevent against SQL injection attacks. In addition, during development in some instances LocalSQLDB
database system is used and during deployment you usually need to use the production SQL server database. Moreover, Linq-to-SQL is used on Windows Phone 8.1 and it is required for phone development later and so I highly recommend learning
it if you plan on developing windows phone applications.
@System243trd, If you want the code for the windows phone app I think it uses the MVVM model or that might be for universal apps or regular windows phone apps. I have been using the windows phone Silverlight pivot or panorama template (it might
be pieces of both). I've already submitted to the windows phone marketplace and it had to go through certification first. I plan on later making an article on it but I need to first fix one or two simple problems I have with it. Here's a link to
the source code if you later want to look at the source code (in vb.net):
https://jeffsblogcodesamples.codeplex.com/downloads/get/1445836
Once you eliminate the impossible, whatever remains, no matter how improbable, must be the truth. - Sherlock Holmes. speak softly and carry a big stick - theodore roosevelt. Fear leads to anger, anger leads to hate, hate leads to suffering - Yoda. Blog
- http://www.computerprofessions.us -
Connection to multiple databases using a single EJB
How can I connect to multiple Databases (using @PersistenceContext) using an EJB?
Did I need to connect various Entity Managers corresponding to the each database and simply send my Queries?
I am using Glassfish Application Server
Netbeans IDE
Java Derby Database
Oracle Database
Java Persistence API
Thanks in AdvanceYes, you need a persistence context and thus entity manager per database. Depending on what you want to achieve you may also need to go to the next level in your skill set and learn all about distributed transactions.
-
How do the application servers connect the new database after failing over from primary DB to standby DB?
We have setup a DR environment with a standalone Primary server and a standalone Physical Standby server on RHEL Linux 6.4. Now our application team would like to know:
When the primary DB server is crashed, the standy DB server will takeover the role of primary DB through the DataGuard fast failover. As the applications are connected by the primary DB IP before,currently the physical DB is used as a different IP or listener. If this is happened, they need to stop their application servers and re-configure their connection so the they coonect the new DB server, they cannot tolerate these workaround.
Whether does oracle have the better solution for this so that the application can automatically know the role's transition and change to the new IP without re-confige any connection and shutdown their application?
Oracle support provides us the answer as following:
==================================================================
Applications connected to a primary database can transparently failover to the new primary database upon an Oracle Data Guard role transition. Integration with Fast Application Notification (FAN) provides fast failover for integrated clients.
After a failover, the broker publishes Fast Application Notification (FAN) events. These FAN events can be used in the following ways:
Applications can use FAN without programmatic changes if they use one of these Oracle integrated database clients: Oracle Database JDBC, Oracle Database Oracle Call Interface (OCI), and Oracle Data Provider for .NET ( ODP.NET). These clients can be configured for Fast Connection Failover (FCF) to automatically connect to a new primary database after a failover.
JAVA applications can use FAN programmatically by using the JDBC FAN application programming interface to subscribe to FAN events and to execute event handling actions upon the receipt of an event.
FAN server-side callouts can be configured on the database tier.
FAN events are published using Oracle Notification Services (ONS) and Oracle Streams Advanced Queuing (AQ).
=======================================================================================
Who has the experience and the related documentation or other solutions? we don't have the concept of about FAN.
Thank very much in advance.Hi mesbeg,
Thanks alot.
For example, there is an application JBOSS server connecting the DB, we just added another datasource and put the standby IP into the configuration file except adding a service on DB side like this following:
<subsystem xmlns="urn:jboss:domain:datasources:1.0">
<datasources>
<datasource jta="false" jndi-name="java:/jdbc/idserverDatasource" pool-name="IDServerDataSource" enabled="true" use-java-context="true">
<connection-url>jdbc:oracle:thin:@<primay DB IP>:1521:testdb</connection-url>
<connection-url>jdbc:oracle:thin:@<standby DB IP>:1521:testdb</connection-url>
<driver>oracle</driver>
<pool>
<min-pool-size>2</min-pool-size>
<max-pool-size>10</max-pool-size>
<prefill>true</prefill>
</pool>
<security>
<user-name>TEST_USER</user-name>
<password>Password1</password>
</security>
<validation>
<valid-connection-checker class-name="org.jboss.jca.adapters.jdbc.extensions.oracle.OracleValidConnectionChecker"/>
<validate-on-match>false</validate-on-match>
<background-validation>false</background-validation>
<use-fast-fail>false</use-fast-fail>
<stale-connection-checker class-name="org.jboss.jca.adapters.jdbc.extensions.oracle.OracleStaleConnectionChecker"/>
<exception-sorter class-name="org.jboss.jca.adapters.jdbc.extensions.oracle.OracleExceptionSorter"/>
</validation>
</datasource>
<drivers>
<driver name="oracle" module="com.oracle.jdbc">
<xa-datasource-class>oracle.jdbc.OracleDriver</xa-datasource-class>
</driver>
</drivers>
</datasources>
</subsystem>
If the failover is occurred, the JBOSS will automatically be pointed to the standby DB. Additional actions are not needed. -
Connecting to Multiple database
Hi how could i use Dreamweaver CS3 to connect to multiple
databases in phpmyadmin?Maneet Puri wrote:
> Hi,
>
> I have used a lot the extensions of Dreamweaver for
implementing various
> dynamic features with connectivity to MySQL databases,
and I don't think there
> is any extension which allows connecting to the multiple
MySQL database. To do
> this you will have to make changes to scripts, at one
point of time from one
> script in one instance there can just be one connection
to one MySQL database,
> what you can do is switch between the users and database
of mysql. PHP offers a
> function mysql_change_user() to switch users and connect
to various different
> MySQL database.
What is stopping you from having more than one database
connection
string? You can select the connection from each behaviour
that needs
different databases.
Or is then intent to combine the data from 2 database into
one recordset?
Dooza
Posting Guidelines
http://www.adobe.com/support/forums/guidelines.html
How To Ask Smart Questions
http://www.catb.org/esr/faqs/smart-questions.html -
Help using C# application to connect to oracle database
I'm new to database.
I'm developing a C# GUI application in visual studio 2008 that is suppose to interact with oracle. After researching and trying out several sample codes, nothing works and I'm in desperate need of some help/advice/suggestions.
The simplest example I'm trying is to just get a button to run a simple SQL query. The code is:
private void button1_Click(object sender, EventArgs e)
string oradb = "Data Source=acme.gatech.edu;User Id=gtg880f;Password=******;";
OracleConnection conn = new OracleConnection(oradb); // C#
conn.Open();
OracleCommand cmd = new OracleCommand();
cmd.Connection = conn;
cmd.CommandText = "select Location_Name from warehouse where Location_name = 'atlanta'";
cmd.CommandType = CommandType.Text;
OracleDataReader dr = cmd.ExecuteReader();
dr.Read();
label1.Text = dr.GetString(0);
conn.Dispose();
I've installed many many version of oracle database and have included the Oracle.Data.Access under reference.
If I use putty and connect to acme.gatech.edu via port 22, I can type sqlplus / and run the query "elect Location_Name from warehouse where Location_name = 'atlanta'" and it'll work.
After some research, some say that if I can connect via sqlplus that means i can connect to the database but what do i need to implement to enable my c# code in visual studio to be able to do that.
I did a search on the forum but found nothing that matches this. In essence, I'm not sure what/how to specify such that I can connect to the acme.gatech.edu server and run sql commands.
Thanks,
Oky SabeniThere're two ways you can get data in and out of database using .NET
#1 System.Data.OracleClient namespace - it's .NET avail out of the box
#2 Oracle.DataAccess.Client - aka "ODP.NET"
Download: http://www.oracle.com/technology/software/tech/windows/odpnet/index.html
Or download Beta because as of today it's the only version which supports .NET "TransactionScope" (I just tested seems like still it is NOT working Re: 10g Express + ODP.NET (version 2.111.6.20) > support TransactionScope? http://www.oracle.com/technology/software/tech/windows/odpnet/index1110710beta.html
QuickStart: http://www.installationwiki.org/ODP.NET_Getting_Started_Guide
Also there's a doc under Start menu>Programs>Oracle - OraOdac11g_BETA_home>Application Development>"Oracle Data Provider for .NET Developer's Guide"
It's worth reading just scroll down quick for code fragment.
Anyway here's two small examples:
Example 1: System.Data.OracleClient (Using library from M$)
* First you'll need to add reference to "System.Data.OracleClient".
IDbFactory oDbFactory = DbProviderFactories.GetFactory("System.Data.OracleClient");
IDbConnection oConn = oDbFactory.CreateConnection();
oConn.ConnectionString = "Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=MyHost)(PORT=MyPort))(CONNECT_DATA=(SERVICE_NAME=MyOracleSID)));User Id=myUsername;Password=myPassword;";
// Or ...
oConn = new System.Data.OracleClient.OracleConnection("Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=MyHost)(PORT=MyPort))(CONNECT_DATA=(SERVICE_NAME=MyOracleSID)));User Id=myUsername;Password=myPassword;");
Example 2: ODP.NET from Oracle
IDbFactory oDbFactory = DbProviderFactories.GetFactory("Oracle.DataAccess.Client");
IDbConnection oConn = oDbFactory.CreateConnection();
oConn.ConnectionString = "Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=MyHost)(PORT=MyPort)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=MyOracleSID)));User Id=myUsername;Password=myPassword;";
// Or ...
oConn = new Oracle.DataAccess.Client.OracleConnection("Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=MyHost)(PORT=MyPort)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=MyOracleSID)));User Id=myUsername;Password=myPassword;");
string strSQL = "... SQL statement...";
int nPersonId = 0;
string strFirstName = null;
Person oPerson = null;
string strSQL = "SELECT Id FROM PERSON";
oCmd = oConn.CreateCommand();
oCmd.CommandText = strSQL;
oCmd.CommandType = System.Data.CommandType.Text;
IDataReader oRdr = oCmd.ExecuteReader();
while (oRdr.Read())
if (!Convert.IsDBNull(oRdr["Id"]))
nPersonId = (int) oRdr["Id"];
if (!Convert.IsDBNull(oRdr["FirstName"]))
strFirstName = (string)oRdr["FirstName"];
oPerson.Id = nPersonId;
oPerson.FirstName = strFirstName;
Example CREATE TABLE:
DECLARE
count_item int;
BEGIN
SELECT count(1) into count_item FROM user_sequences WHERE sequence_name = 'AUDITLOGSEQUENCE';
IF count_item > 0 THEN
begin
dbms_output.put_line('drop sequence AUDITLOGSEQUENCE');
EXECUTE IMMEDIATE ('DROP SEQUENCE AUDITLOGSEQUENCE');
end;
ELSE
dbms_output.put_line('no need to drop AUDITLOGSEQUENCE');
END IF;
EXECUTE IMMEDIATE 'CREATE SEQUENCE AUDITLOGSEQUENCE
MINVALUE 1
MAXVALUE 999999999999999999999999999
START WITH 1
INCREMENT BY 1
CACHE 20';
dbms_output.put_line('AUDITLOGSEQUENCE created');
SELECT count(1) into count_item FROM user_tables WHERE table_name = 'LOG';
IF count_item > 0 THEN
begin
dbms_output.put_line('drop table LOG');
EXECUTE IMMEDIATE ('DROP TABLE LOG');
end;
ELSE
dbms_output.put_line('no need to drop table LOG');
END IF;
EXECUTE IMMEDIATE '
CREATE TABLE LOG (
Id numeric(19,0) NOT NULL,
CreateDate timestamp default sysdate NOT NULL,
Thread varchar (510) NULL,
LogLevel varchar (100) NULL,
Logger varchar (510) NULL,
Message varchar (4000) NULL,
InnerException varchar (4000) NULL,
CONSTRAINT PK_LOG PRIMARY KEY (Id)
COMMIT;
dbms_output.put_line('table LOG created');
dbms_output.put_line('setup complete');
EXCEPTION
WHEN OTHERS THEN
dbms_output.put_line('*** setup exception detected! ***');
dbms_output.put_line('error code: ' || sqlcode);
dbms_output.put_line('stack trace: ' || dbms_utility.format_error_backtrace);
RAISE_APPLICATION_ERROR(-20000, 'AuditTrail.oracle.tables.sql - install failed');
END;
Before running script, make sure your account has permission (unless you're using SYS account of course). You'd probably need to know how to create user and granther right:
CREATE USER dev IDENTIFIED BY "devacc_@";
GRANT CREATE SESSION TO DEV;
GRANT DBA TO DEV;
Here's how you can run PL\SQL scripts in Oracle
SQL*Plus: Release 10.2.0.1.0 - Production on Mon Apr 6 14:10:05 2009
Copyright (c) 1982, 2005, Oracle. All rights reserved.
SQL> connect devvvy/"somepwd"
Connected.
SQL> set serveroutput on
SQL> @C:\dev\UnitTest\Util\Command\sql\Oracle\SetupSchema\xxxxx.oracle.tables.sql
1125 /
SQL> @C:\dev\Util\Command\sql\Oracle\SetupSchema\xxxxx.oracle.tables.data.only.sql
560 /
PL/SQL procedure successfully completed.
SQL> @C:\dev\Util\Command\sql\Oracle\SetupSchema\AuditTrail.oracle.tables.sql
54 /
PL/SQL procedure successfully completed.
SQL> COMMIT;
Remeber however:
(a) SQL*Plus does not like "&" in your SQL script. Do comment or string containing "&" should be taken out.
(b) password should not contain "@" because it's a special character in "CONNECT" command.
Alternative, download TOAD for Oracle - http://www.toadsoft.com/toad_oracle.htm
(c) After command, type "/" next line to get command executed.
(d) remember to COMMIT
REF for Oracle:
Oracle Official doc: http://www.oracle.com/pls/db111/portal.portal_db?selected=1&frame=
Oracle 11g configuration Guide: http://www.thegeekstuff.com/2008/10/oracle-11g-step-by-step-installation-guide-with-screenshots/
ODAC/ODP.NET QuickStart: http://www.installationwiki.org/ODP.NET_Getting_Started_Guide
ODP.NET versioning scheme: http://download.oracle.com/docs/html/E10927_01/InstallVersioningScheme.htm
SQLPlus basic: http://download.oracle.com/docs/cd/B25329_01/doc/appdev.102/b25108/xedev_sqlplus.htm#CJAGGHGE
PL\SQL:
Cheat sheet: http://en.wikibooks.org/wiki/Oracle_Programming/SQL_Cheatsheet
Reference:
http://www.rocket99.com/techref/oracle_plsql.html
http://download-uk.oracle.com/docs/cd/B19306_01/appdev.102/b14261/toc.htm
EXECUTE IMMEDIATE, DROP/CREATE TABLE: http://www.java2s.com/Code/Oracle/PL-SQL/Callexecuteimmediatetodroptablecreatetableandinsertdata.htm
Exception handling: http://download.oracle.com/docs/cd/B10501_01/appdev.920/a96624/07_errs.htm
Named Block syntax: http://www.java2s.com/Tutorial/Oracle/0440__PL-SQL-Statements/Thestructureofanamedblock.htm
CREATE PROCEDURE: http://it.toolbox.com/blogs/oracle-guide/learn-plsql-procedures-and-functions-13030
Oracle DataType: http://www.ss64.com/orasyntax/datatypes.html
http://www.adp-gmbh.ch/ora/misc/datatypes/index.html
Oracle Sequence and Create table: http://www.java2s.com/Tutorial/Oracle/0100__Sequences/Usingasequencetopopulateatablescolumn.htm -
Java Application to connect to vdb3 database
Hi Folks,
I have to create a java application to connect to vdb3 oracle databse to support various transactions with menu options as below:
File menu(ALT F)
---Connect (ALT L)
---Exit (ALT E)
Data menu(ALT D)
---Query(ALT Q)
---Add Student(ALT A)
---Delete Student(ALT T)
---Update Student(ALT U)
Option menu(ALT O)
---Color(ATL C)
---Font (ATL N)
There is a STUDENT table with studid, firstname, lastname, major and age.
I have the following code for the GUI. I am getting the following errors. How do I go about from here? Please help.
Student.java:13: cannot find symbol
symbol : class ControlPanel
location: class Student
private ControlPanel controls;
^
Student.java:38: cannot find symbol
symbol: method GridLayout(int,int,int,int)
frame.add(panel, GridLayout(4,2,5,5));
^
Student.java:49: cannot find symbol
symbol : method addWindowListener(<anonymous java.awt.event.WindowAdapter>)
location: class javax.swing.JMenuItem
exititem.addWindowListener(
^
Student.java:69: cannot find symbol
symbol : method JMenuItem(java.lang.String)
location: class Student
JMenuItem queryItem = JMenuItem("Query");
^
Student.java:78: cannot find symbol
symbol : method showMessgaeDialog(<nulltype>,java.awt.Component,java.lang.String,int)
location: class javax.swing.JOptionPane
JOptionPane.showMessgaeDialog(null, add(queryoutput), "QUERY RESULTS", JOptionPane.INFORMATION_MESSAGE);
import javax.swing.*;
import java.sql.*;
import java.awt.*;
import java.awt.event.*;
public class Student extends JFrame
private JTextArea out;
private JDesktopPane desktop;
private JTextArea queryoutput;
private ControlPanel controls;
public Student()
super(" Student Database");
//container c = getContentPane();
desktop = new JDesktopPane();
add(desktop);
JMenu fileMenu = new JMenu("File");
fileMenu.setMnemonic('F');
JMenuItem connectItem = new JMenuItem("Connect");
connectItem.setMnemonic('L');
fileMenu.add(connectItem);
connectItem.addActionListener(
new ActionListener()
public void actionPerformed(ActionEvent event)
JInternalFrame frame = new JInternalFrame("Login", true, true, true, true );
MyPanel panel = new MyPanel();
frame.add(panel, GridLayout(4,2,5,5));
frame.pack();
desktop.add(frame);
frame.setVisible(true);
JMenuItem exititem = new JMenuItem("Exit");
exititem.setMnemonic('E');
fileMenu.add(exititem);
exititem.addWindowListener(
new WindowAdapter()
public void WindowClosing (WindowEvent event)
System.exit(0);
JMenuBar bar = new JMenuBar();
setJMenuBar(bar);
bar.add(fileMenu);
queryoutput = new JTextArea(5,20);
JMenu dataMenu = new JMenu("Data");
dataMenu.setMnemonic('D');
JMenuItem queryItem = JMenuItem("Query");
queryItem.setMnemonic('Q');
dataMenu.add(queryItem);
dataMenu.addSeparator();
dataMenu.addActionListener(
new ActionListener()
public void actionPerformed(ActionEvent event)
JOptionPane.showMessgaeDialog(null, add(queryoutput), "QUERY RESULTS", JOptionPane.INFORMATION_MESSAGE);
JMenuItem addstud = new JMenuItem("Add Student");
addstud.setMnemonic('A');
dataMenu.add(addstud);
dataMenu.addActionListener(
new ActionListener()
public void actionPerformed(ActionEvent event)
JMenuItem delstud = new JMenuItem("Delete Student");
addstud.setMnemonic('T');
dataMenu.add(delstud);
dataMenu.addActionListener(
new ActionListener()
public void actionPerformed(ActionEvent event)
JMenuItem updatestud = new JMenuItem("Update Student");
addstud.setMnemonic('U');
dataMenu.add(updatestud);
dataMenu.addActionListener(
new ActionListener()
public void actionPerformed(ActionEvent event)
JMenu options = new JMenu("Options");
options.setMnemonic('O');
JMenuItem color = new JMenuItem("Color");
addstud.setMnemonic('C');
options.add(color);
options.addActionListener(
new ActionListener()
public void actionPerformed(ActionEvent event)
JMenuItem font = new JMenuItem("Font");
addstud.setMnemonic('N');
options.add(font);
options.addActionListener(
new ActionListener()
public void actionPerformed(ActionEvent event)
class MyPanel extends JPanel
private JLabel L1;
private JLabel L2;
private JLabel L3;
private JTextField userid;
private JPasswordField pw;
private JTextField database;
private JButton ok;
private Connection connect;
private JTextArea output;
private String url;
public MyPanel()
L1 = new JLabel("User Id:");
add(L1);
userid = new JTextField(10);
add(userid);
L2 = new JLabel("Password:");
add(L2);
pw = new JPasswordField(10);
add(pw);
L3 = new JLabel("Database Name:");
add(L3);
database = new JTextField(10);
add(database);
ok = new JButton("OK");
add(ok);
ok.addActionListener(
new ActionListener()
public void actionPerformed(ActionEvent event)
try {
url = "jdbc:odbc:Student";
Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver" );
connect = DriverManager.getConnection( url );
output.append( "Connection successful\n" );
catch ( ClassNotFoundException cnfex ) {
// process ClassNotFoundExceptions here
cnfex.printStackTrace();
output.append( "Connection unsuccessful\n" +
cnfex.toString() );
catch ( SQLException sqlex ) {
// process SQLExceptions here
sqlex.printStackTrace();
output.append( "Connection unsuccessful\n" +
sqlex.toString() );
catch ( Exception ex ) {
// process remaining Exceptions here
ex.printStackTrace();
output.append( ex.toString() );
import javax.swing.*;
public class MainWindow
public static void main( String args[])
Student student = new Student();
student.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
student.setSize(500,200);
student.setVisible( true);
}Error messages tell you everything you need to know (usually).
Student.java:13: cannot find symbol
symbol : class ControlPanel
location: class Student
private ControlPanel controls;
^
This means that the compiler cannot find the class ControlPanel. Does it exists. Is it in the same directory as your other files. Has it compiled correctly.
Student.java:38: cannot find symbol
symbol: method GridLayout(int,int,int,int)
frame.add(panel, GridLayout(4,2,5,5));
^
This tells you it cannot find the method GridLayout. I presume you meant to have a new in front of it. Besides the layout manager code should have been done prior to this and your code should be
frame.add(panel);Student.java:49: cannot find symbol
symbol : method addWindowListener(<anonymous java.awt.event.WindowAdapter>)
location: class javax.swing.JMenuItem
exititem.addWindowListener(
^
Once again the method addWindowListener cannot be found. JFrame has this method not JMenuItem. Probably need an ActionListener.
Student.java:69: cannot find symbol
symbol : method JMenuItem(java.lang.String)
location: class Student
JMenuItem queryItem = JMenuItem("Query");
^
Once again the compiler thinks you are trying to call a method called JMenuItem. You forgot new.
Student.java:78: cannot find symbol
symbol : method showMessgaeDialog(<nulltype>,java.awt.Component,java.lang.String,int)
location: class javax.swing.JOptionPane
JOptionPane.showMessgaeDialog(null, add(queryoutput), "QUERY RESULTS", JOptionPane.INFORMATION_MESSAGE);
Spelling! -
Root Application Module connecting to 2 databases technologies
I have an application which needs to connect to 2 different databases.
I managed to get access to each databases in their own respective Application Modules.
In order to achieve that, I created a new ViewObject within the "oracle" model, and still used the "MySQL" query. Using the jbo.envinfoprovider property, I can force the Application module to connect to the appropriate database, MySQL in this case.
Now, my problem is that I need to have a Root application module that will use BOTH "child" application module and eventually BOTH database connections. At the moment, I can only use one at a time. Using the jbo.envinfoprovider property of the ROOT application module allows me to select which of the 2 database I want to use, but I need both.
To put it in a tree-like structure, here's what I want to achieve :
ROOT (Oracle + MySQL)
|
|__ AppModule1 (Oracle)
| |
| |__ View1
| |__ View2
|
|__ AppModule2 (MySQL)
|
|_ View3What I mean is if I deploy the application on the integrated weblogic server, using the default navigation flow defined in the adfc-config.xml file, when I reach the "forensic" page, it will try to "read" from both database and fail at reading the second database.
The page displays the following :
1- a table containing the records from the Oracle database (3 columns=> ID, pattern, solution)
2- an adf_form used to populate the above table :
- the ID is bound to a database trigger, so is set to readonly
- the solution is a text input field
- the Pattern is a LoV, based on the data found on the MySQL database.
If I test the page from the "forensic.jspx" itself (by right-clicking and selecting "Run"), I can manage the data just fine (I can do any CRUD operations I want)
on the other hand, if I go to the "adfc-config.xml" file and (right-click and then select "Run"), the page will only read one of the two database (I can control which one, by changing the jbo.envinfoprovider property of my application module)
Hope this helps understand what I am trying to achieve.
Thanks ! -
Same application that works on different database user
I have an application wiritten in htmldb 1.6 taht create areport on a table.
But on the database i have a lot of different user (each table of each user have different information)
Can i use the same application with connection on differnet user???
Thank's again ....Hi Algervis,
There is a lots of issue to get actual solution of your problem .
If your previous application that use the HTMLDB 1.6 to create a report based on the underlying tables for that particular schema.But if like to switch into different schema for that database then you have to create a workspace pointing to the intended schema which have the same underlying table details as earlier and you have to deploy your application for that schema to re-use it .So the deployed application must use the same tables that your earlier schema does otherwise the application may fail to generate the report.
Hope this might be useful.
Thanks & Regards,
ROSY -
Oracle Application server connection pool and database links
I am using Oracle application server 10g with connection pools, the db used by the application connects to another oracle db using a database link. My question is when the application starts it creates 10 connections, does it also create x amount of database links as well?
Hi,
Is there any way to use the connection pool or Datasource while connecting to database?If I am using a stateless sesssion bean and using a Data Access layer which just creates a database session to write the persistence toplink objects how I can make use of application server connection pool?Hi Vinod,
Yes, TopLink allows you to use the app server's connection pooling and transaction services. Chapter 2 of the Oracle9iAS TopLink Foundation Library Guide provides details as do the TopLink examples. The easiest way to set this up is by using the sessions.xml file. The sample XML below is from the file <toplink903>\examples\ias\examples\ejb\sessionbean\sessions.xml. Here we are adding the datasource defined in OC4J and specifying that we are using the OC4J transaction controller also.
<login>
<user-name>sa</user-name>
<password></password>
<datasource>java:comp/env/jdbc/ejbJTSDataSource</datasource>
<uses-external-transaction-controller>true</uses-external-transaction-controller>
<uses-external-connection-pool>true</uses-external-connection-pool>
</login>
<external-transaction-controller-class>oracle.toplink.jts.oracle9i.Oracle9iJTSExternalTransactionController</external-transaction-controller-class>
When using this approach you need to change your TopLink code slightly in the EJB methods:
a. Acquire the ACTIVE unit of work from the server
session (again, see the EmployeeSessionEJB code
example) with something like:
UnitOfWork uow = clientSession.getActiveUnitOfWork();
b. Calls to uow.commit() can be ommitted or commented out
because the EJB will handle this. Note that of course
the methods you create in the EJB that are using this
approach must have TX Required (default).
Hope this helps.
Pete -
Error Deploying Web application that Connects to MS SQL Server
Hello I have Created a data Source that connects to a SQL Server Database and its conecting but whenever i try running the web server that contains a web page that accesses a Datasource (Microsoft) I get this error
Exception is: Exception creating connection pool. Exception: oracle.oc4j.sql.config.DataSourceConfigException: Unable to create : com.microsoft.sqlserver.jdbc.SQLServerDriver
06/04/26 12:26:37 SEVERE: ApplicationStateRunning.initConnector Stack trace: oracle.oc4j.sql.DataSourceException: Exception creating connection pool. Exception: oracle.oc4j.sql.config.DataSourceConfigException: Unable to create : com.microsoft.sqlserver.jdbc.SQLServerDriver
at com.evermind.server.ApplicationStateRunning.initDataSourceConnectionPool(ApplicationStateRunning.java:2016)
Even though I chose the option to Upload the library with the deployment, Do i have to manually load the SQL Server Librarieswith com.microsoft.sqlserver.jdbc.SQLServerDataSource it does'nt get created.. with com.microsoft.sqlserver.jdbc.SQLServerDriver it does get created
-
Does BO 4.1 enable universe to connect to multiple database?
Using BO 3.1, we can only connect an universe to single database. However, with BO 4.1 will it be possible to connect a single universe to multiple database?
Regards
VinayVinay, You can connect Universe to multiple databases using IDT (Information Design Tool). Find the below link for reference.
SAP Business Objects Multi Source Universe - Information Design Tool - YouTube
Regards,
Sujitha -
Is it possible to create a new Universe that connects to this database?
I know that BO universes can be linked to Sybase, Access, Oracle databases, etc. but i don't know if it is possible to create a universe with a connection to a Firebird database .
Is it possible? In Universe Designer I try to create a new connection using the Connection Wizard, then I press Next and then it displays a list of databases nodes, but I can't find an option for Firebird. Which option should I select? Can I select Generic ODBC datasource?
Has someone else used Firebird for his/her universes?
Edited by: PadawanGirl on Nov 24, 2010 8:53 PMHi,
I would like to give you a workaround for your problem.
If you have BO Server installed on your machine then do the following
-> Go to 'Central Configuration Mangager(CCM)'
-> Right Click on 'Server Intelligence Agent(SIA)' and click 'STOP' then
-> Double click on 'Server Intelligence Agent(SIA)'
-> Go to 'Configuration' Tab
-> Click 'SPECIFY' on 'CMS System Database Configuration' button then
-> Select any one of the 3 options(depending on ur requirement) and connect to ur Database (Firebird) by giving the credentials of ur database.
-> After doing all the necessary things Restart the SIA by clicking the buttion START on CCM and now check if u r getting Firebird database while creating a new connection.
This is just a workaround. I hope this would b helpful to you. Please try this and see if its useful to you.
Thanks. -
Problem with connection to multiple Databases
i'm trying to write a sql query that returns data from tables that reside in
different databases on different servers, STYX and MICA to be exact.
I log into STYX and write the following simple SQL statement (what is
returned is really irrelevant, i'm just trying to figure out the process
right now)
select a.reason_code, b.reason
from [email protected] a,
hedgessw.reason_code b
where a.reason_code = b.reason_code
hedgessw.reason_code is on STYX
the other table is on MICA
i get the following error code
ORA-02019: connection description for remote database not found
this seems to imply that i need to create a "connection description" for the
remote database before i can establish the link.
is this the case?
if so, how do i create this?
any help you can offer would be greatly appreciated!
thanks in advance
nullWhat error messages are you getting?
What happens when you try to display the page?
General comments
- JSPs shouldn't be connecting to databases. That should be done in the data access layer, not the view layer. Put the code in beans/java code.
- Why reinvent the wheel? There are a couple of excellent taglibs out there that already do DB connections. Check out the JSTL sql tags. -
Publishing as web service an application that connects with Oracle 8i
Hi.
I have to execute a stored procedure in a 8i database (database migration or upgrade is not a possibiity). I have to incorporate this into an ADF 11g App and I've tried it making another project and using the 10g jdbc driver which allows me to execute that SP.
When I execute SP call, everything is OK, but when I try to call from the main app, there are conflicts with 11g driver and execution fails, because, I think, in the classpath is first 11g driver reference and it uses this river class instead 10g drivers.
Now I'm trying with a separate app which just call the SP. I put the same code, and again when I run it as standalone app everything is OK, but when I deploy it as a web service and run it from WS test it doesn't work and again results in the same error above.
java.lang.ArrayIndexOutOfBoundsException: 7
at oracle.jdbc.driver.T4CConnection.connect(T4CConnection.java:989)
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:292)
at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:
508)
at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:203)
at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtensio
n.java:33)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:510)
at java.sql.DriverManager.getConnection(DriverManager.java:582)
at java.sql.DriverManager.getConnection(DriverManager.java:185)
at credito.wsutil.stage.SCL.execSpCartera(SCL.java:80)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at weblogic.wsee.jaxws.WLSInstanceResolver$WLSInvoker.invoke(WLSInstance
Resolver.java:101)
at weblogic.wsee.jaxws.WLSInstanceResolver$WLSInvoker.invoke(WLSInstance
Resolver.java:83)
at com.sun.xml.ws.server.InvokerTube$2.invoke(InvokerTube.java:152)
at com.sun.xml.ws.server.sei.EndpointMethodHandler.invoke(EndpointMethod
Handler.java:264)
at com.sun.xml.ws.server.sei.SEIInvokerTube.processRequest(SEIInvokerTub
e.java:93)
at com.sun.xml.ws.api.pipe.Fiber.__doRun(Fiber.java:604)
at com.sun.xml.ws.api.pipe.Fiber._doRun(Fiber.java:563)
at com.sun.xml.ws.api.pipe.Fiber.doRun(Fiber.java:548)
at com.sun.xml.ws.api.pipe.Fiber.runSync(Fiber.java:445)
at com.sun.xml.ws.server.WSEndpointImpl$2.process(WSEndpointImpl.java:24
9)
at com.sun.xml.ws.transport.http.HttpAdapter$HttpToolkit.handle(HttpAdap
ter.java:453)
at com.sun.xml.ws.transport.http.HttpAdapter.handle(HttpAdapter.java:250
at com.sun.xml.ws.transport.http.servlet.ServletAdapter.handle(ServletAd
apter.java:140)
at weblogic.wsee.jaxws.HttpServletAdapter$AuthorizedInvoke.run(HttpServl
etAdapter.java:298)
at weblogic.wsee.jaxws.HttpServletAdapter.post(HttpServletAdapter.java:2
11)
at weblogic.wsee.jaxws.JAXWSServlet.doPost(JAXWSServlet.java:297)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
at weblogic.wsee.jaxws.JAXWSServlet.service(JAXWSServlet.java:87)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run
(StubSecurityHelper.java:227)
at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecuri
tyHelper.java:125)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.jav
a:292)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.jav
a:175)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationActio
n.run(WebAppServletContext.java:3590)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(Authenticate
dSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:
121)
at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppS
ervletContext.java:2200)
at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletC
ontext.java:2106)
at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.j
ava:1428)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)
Any suggestions or another way to accomplish this functionality?
Regards,
DEMRHi,
This was what I did when I was trying to run Hibernate on Weblogic, it was conflicting with different versions of antlr.* packages in Weblogic. Then I added these lines for making Weblogic to use Hibernate's antlr libs instead of installed on Weblogic.
So, I thought that it might help to solve your problem if Oracle drivers conflict with drivers pre-installed in Weblogic.
Also can you please try to add in your weblogic-application.xml, if it still does not solve your problem unfortunately I don't know any other way to solve your problem.
<prefer-application-packages>
<package-name>oracle.jdbc.*</package-name>
</prefer-application-packages> Edited by: Onur Aktaş on 30.Eyl.2009 08:31
Maybe you are looking for
-
HT4279 ATI Radeon HD 5870 screen resets size after after sleeping. Why?
Purchased an ATI Radeon HD 5870. When connected to 1920x1080 it leaves a third of the screen out. However after starting up it fits the screen. Only after sleeping does it reset to this faulty screen size. I have attempted every Mini dv adapter vga,d
-
Keeping my BT Yahoo Premium Mail Account, I am hav...
I cancelled my BT Broadband Option 3 subscription around Nov 20th 2011 and I discovered on the internet that my BT Yahoo Premium mail would be terminated 90 days after my BT Broadband was cancelled, I've had my bt email account for around 10 years so
-
Error during the installation of ORACLE 10g for SAP MDM 5.5
Hi all, I am installing ORACLE 10g on a SUSE LES 9 for a future MDM 5.5 system. While I launch the Installer I get the following error: Preparing to launch Oracle Universal Installer from /tmp/OraInstall2007-09-26_07-11-46AM. Please wait ...oracle@mu
-
Pricing details of sales order
Hi SAP GURUs, I want to make report of pricing details of sales orders. From which table i should get the pricing details. I know tables KONH and KONP...but i dont know how to get details in these tables for perticuler sales order. Please help me out
-
Which HDD connection is faster -- Internal ATA or External Firewire?
I want to set up a HDD as a scratch drive for Photoshop. Which connection would be faster -- hooking it up to my internal ATA 100 cable or an external firewire enclosure? I do not have a drive presently hooked up to my ATA 100 cable since I'm running