UserTransactions without JDBC?
Hi!
Is it possible to use UserTransactions without JDBC and EJBs.
I tried this (with WebSphere 3.5):
int i=1;
utx.begin();
i++;
utx.rollback();
System.out.println(i);
But the rollback does not work.
The output is 2 and not 1.
Is there a possibility to do something like that?
cu...
Torsten
Hi,
A transaction in JTA only spans work done through javax.transaction.xa.XAResource instances.
The rollback will only work for resources that are enlisted with the transaction.
In fact, an instance of XAResource in a handle to a transactional context on some object. To make it work for your case, you would have to implement an object that encapsulates the i counter, and is able to return an XAResource that can be enlisted with the transaction.
The rollback method would then restore the previous value of i.
Making this work in a valid way would require logging the state of the object as well, since XAResources can be prepared (meaning that the work can still be rolled back, but needs to be recoverable after a crash).
Best,
Guy
Similar Messages
-
Can i access my database without jdbc
Can i access my database without jdbc
i don't want use a driver are there other methods for accessing database or is jdbc the only way for connecting a databaseI would sure like to know any one of the ways that you mention below
Where would be a good place to start
This is not a good place for that kind of research.
If you have a problem that needs solving, come here.
I could probably think up a couple of ways to access
s a database from Java without using JDBC, but no
sensible programmer would ever dream of trying to use
them. So they would just make your research look
stupid. -
Data transfer from SQLDB to SAP R/3 without JDBC adapter
Hi Experts,
Please suggest the possible methods of transferring data from SQLDB to SAP R/3 without using a JDBC adapter at sender side.
Regards,
KalyanHi KKC242 ,
Please suggest the possible methods of transferring data from SQLDB to SAP R/3 without using a JDBC adapter at sender side.
> Data links can work..but not recommended..and that too will be with out using PI.
any way we hav eto connect to the database...even without adapter..by using a OLEDB/JDBC connector...in VB.. an dsend it across to PI
Regards , -
I copy ant code from http://middlewaremagic.com/weblogic/?p=2504 and change it as follow. I use weblogic 10.3.4
New datasources can be created. However, the JNDI name is not complete. It doesn't contain jdbc/
<?xml version="1.0" ?>
<project name="deploy" default="makeDataSource" basedir=".">
<property name="wls.username" value="weblogic" />
<property name="wls.password" value="welcome1" />
<property name="wls.url" value="t3://localhost:7001" />
<property name="wls.targetServer" value="AdminServer" />
<property name="wls.domainName" value="SOAdomain5" />
<!--<property name="database.url" value="jdbc:pointbase:server://localhost:9092/demo" />-->
<property name="database.url" value="jdbc:oracle:thin:@localhost:1521:orcl"/>
<!--<property name="database.driver" value="com.pointbase.jdbc.jdbcUniversalDriver" />-->
<property name="database.driver" value="oracle.jdbc.xa.client.OracleXADataSource"/>
<property name="database.user" value="dstest" />
<property name="database.password" value="dstest" />
<property name="weblogic.jar" value="E:\Jdeveloper_11115\wlserver_10.3\server\lib" />
<echo message="${weblogic.jar}\weblogic.jar"/>
<taskdef name="wldeploy" classname="weblogic.ant.taskdefs.management.WLDeploy">
<classpath>
<pathelement location="${weblogic.jar}\weblogic.jar"/>
</classpath>
</taskdef>
<taskdef name="wlconfig" classname="weblogic.ant.taskdefs.management.WLConfig">
<classpath>
<pathelement location="${weblogic.jar}\weblogic.jar"/>
</classpath>
</taskdef>
<target name="makeDataSource">
<wlconfig username="${wls.username}" password="${wls.password}" url="${wls.url}">
<query domain="${wls.domainName}" type="Server" name="${wls.targetServer}" property="x" />
<create type="JDBCConnectionPool" name="TestDS">
<set attribute="CapacityIncrement" value="1"/>
<set attribute="DriverName" value="${database.driver}"/>
<set attribute="InitialCapacity" value="1"/>
<set attribute="MaxCapacity" value="10"/>
<set attribute="Password" value="${database.password}"/>
<set attribute="Properties" value="user=${database.user}"/>
<set attribute="RefreshMinutes" value="0"/>
<set attribute="ShrinkPeriodMinutes" value="15"/>
<set attribute="ShrinkingEnabled" value="true"/>
<set attribute="TestConnectionsOnRelease" value="false"/>
<set attribute="TestConnectionsOnReserve" value="true"/>
<set attribute="TestTableName" value="SYSTABLES"/>
<set attribute="URL" value="${database.url}"/>
<set attribute="Targets" value="${x}" />
</create>
<create type="JDBCDataSource" name="TestDS" >
<set attribute="JNDIName" value="jdbc/TestDS"/>
<set attribute="PoolName" value="TestDS"/>
<set attribute="Targets" value="${x}" />
</create>
</wlconfig>
</target>
</project>Thank you. But I get errors. Could you help me to change the code?
Java_home in my computer is C:\Program Files\Java\jdk1.6.0_24
The password and username as well as url are correct. And I can login to wlst using connect('weblogic', 'welcome1', 't3://localhost:7001') in command line
How to start CompatabilityMBeanServer?
------------------------------------------error-----------------------------------
Buildfile: C:\JdevWorkspace\ANTdatasource\Project3\build.xml
[echo] ---13---
[echo] ---16---
makeDataSource:
[echo] ---18---
[wlst] ---1---
[wlst] Connecting to t3://localhost:7001 with userid weblogic ...
[wlst]
[wlst] The CompatabilityMBeanServer is not initialized properly.
[wlst] This might happen if the CompatabilityMBeanServer is
[wlst] disabled via the JMXMBean.
[wlst]
[wlst] To view the root cause exception use dumpStack()
[wlst]
[wlst] WLST detected that the RuntimeMBeanServer is not enabled. This
[wlst] might happen if the RuntimeMBeanServer is disabled via the JMXMBean.
[wlst] Please ensure that this MBeanServer is enabled. Online WLST cannot
[wlst] function without this MBeanServer.
[wlst] Exception in thread "main" java.lang.IllegalStateException: Traceback (innermost last):
[wlst] File "makeDS.py", line 2, in ?
[wlst] File "<iostream>", line 22, in connect
[wlst] File "<iostream>", line 646, in raiseWLSTException
[wlst] WLSTException: Error occured while performing connect : "Cannot connect to WLST."
[wlst] Use dumpStack() to view the full stacktrace
[wlst]
[wlst] at weblogic.management.scripting.WLSTInterpreterInvoker.printError(WLSTInterpreterInvoker.java:110)
[wlst] Traceback (innermost last):
[wlst] File "makeDS.py", line 2, in ?
[wlst] File "<iostream>", line 22, in connect
[wlst] File "<iostream>", line 646, in raiseWLSTException
[wlst] WLSTException: Error occured while performing connect : "Cannot connect to WLST."
[wlst] Use dumpStack() to view the full stacktrace
[wlst]
[wlst] at weblogic.management.scripting.WLSTInterpreterInvoker.executePyScript(WLSTInterpreterInvoker.java:103)
[wlst] at weblogic.management.scripting.WLSTInterpreterInvoker.main(WLSTInterpreterInvoker.java:27)
BUILD FAILED
C:\JdevWorkspace\ANTdatasource\Project3\build.xml:21: Java returned: 1
Total time: 19 seconds
<?xml version="1.0" encoding="UTF-8" ?>
<project name="makeDataSource" default="makeDataSource" basedir=".">
<path id="wl.classpath">
<fileset dir="E:\Jdeveloper_11115\wlserver_10.3\server\lib">
<include name="*.jar"/>
</fileset>
<!--
<fileset dir="E:\Jdeveloper_11115\modules">
<include name="*.jar"/>
</fileset> -->
</path>
<echo message="---13---"/>
<taskdef classpathref="wl.classpath" name="wlst" classname="weblogic.ant.taskdefs.management.WLSTTask" >
</taskdef>
<echo message="---16---"/>
<target name="makeDataSource">
<echo message="---18---"/>
<!--<wlst debug="false" failOnError="true" executeScriptBeforeFile="true" fileName="makeDS.py" classpathref="wl.classpath">-->
<wlst fileName="makeDS.py" debug="false" failOnError="true" executeScriptBeforeFile="true" classpathref="wl.classpath">
<!--<script>
print 'In the target loop'
connect('weblogic','welcome1','t3://localhost:7001')
</script>-->
</wlst>
<echo message="---21---"/>
</target>
</project>
print '---1---'
connect("weblogic","welcome1", "t3://localhost:7001")
edit()
print '---4---'
# Change these names as necessary
dsname="TestDS"
server="AdminServer"
cd("Servers/"+server)
target=cmo
cd("../..")
startEdit()
# start creation
print 'Creating JDBCSystemResource with name '+dsname
jdbcSR = create(dsname,"JDBCSystemResource")
theJDBCResource = jdbcSR.getJDBCResource()
theJDBCResource.setName( dsname )
connectionPoolParams = theJDBCResource.getJDBCConnectionPoolParams()
connectionPoolParams.setConnectionReserveTimeoutSeconds(25)
connectionPoolParams.setMaxCapacity(100)
connectionPoolParams.setTestTableName("dual")
dsParams = theJDBCResource.getJDBCDataSourceParams()
dsParams.addJNDIName("jdbc/TestDs")
driverParams = theJDBCResource.getJDBCDriverParams()
driverParams.setUrl("jdbc:oracle:thin:@localhost:1521:ORCL")
driverParams.setDriverName("oracle.jdbc.driver.OracleDriver")
driverParams.setPassword("welcome1")
driverProperties = driverParams.getProperties()
proper = driverProperties.createProperty("user")
proper.setValue("hr")
jdbcSR.addTarget(target)
save()
activate(block="true")
print 'Done configuring the data source' -
UserTransaction or JDBC transaction
Hi,
please give suggestions...
We are using a application server with connection pooling
jsp and servlets are used in project
for transactions Is userTransaction is better or JDBC transaction is better
userTransaction may be implemented like this
try
getUserTransaction
transaction.begin
execute queries
transaction.commit
catch()
transaction.setRollbackOnly
JDBC Transaction may be implemented like this
connection.autoCommit=false
try
execute queries
connection.commit
catch()
connection.rollback
which is better for scalability and performance when we have to use transactins
in jsp/servlets
regardsHi,
You are talking about using programmatic transactions in J2EE applications.
When developing J2EE applications, you are recommended to use the transaction mechanism provided by the application servers.
Sometimes, JDBC transaction can undertake the whole task. However, using JTA (Java Transaction APIs) is the better choice.
Especially when you are going to develop a lot of components (JavaBeans/ EJBs).
Imangine if a transaction is to be finished after the coroperation of serveral objects(JavaBean/ EJB instances).
How can you control the begining and the ending of the transaction by puting codes in these programs?
But it is very easy to input JTA codes (just like userTransaction etc.) to implement it.
Therefore, to use JTA is more convinient.
Additionally, J2EE specifications recommend to use declarative transactions in EJBs. Thus transaction management could be more flexible.
Good luck.
Gary Wang
Developer Technical Support
Sun Microsystems
http://www.sun.com/developers/support/ -
Hello to everyone,
Is there any way i can connect to a MySQL database without using JDBC? My web host does not support Java unless i go and buy a dedicated Server package which costs a small fortune so i am trying to find a work-around solution. Is there any way i can access a database by combining Java (locally) and PHP on server-side to get data out of the database and back to the Java piece of software?
Thanks to everyone who might see or reply to this postHello deeprave, thanks for replying so quick.
So i guess this is not the best thing to do then. Please allow me to state my problem clearly . Maybe someone might have an answer to my issue. I want to be able to connect Java software on a web server. As deeprave correctly spotted, this can be done using Sockets. Indeed, i have my program connecting to the server.
On my website, i ask users to register themselves in the user database (using standard PHP). Users are then able to log in their account and do stuff. This works fine through the browser.
Issue is at the point where i want my Java software sitting locally on the users machine to be able to connect to the server and authenticate the user. If a user is not registered, the software wont be able to operate (or at least enable user do specific actions). If anyone has any ideas that might help i would be grateful if he/she shares them with me. I am approaching my deadline for submitting my 3rd ear project and i am a bit worried...
Thanks a lot, and excuse me for the long question -
HELP about How to connect with Database without JDBC ?
Hello all,
i have oracel8i database and my programe work fine with JDBC
but now
i want to connect my programe with database without using JDBC connection please any body tell me syntex for that,
Class.forName("oracle.jdbc.driver.OracleDriver");
databaseConnection = DriverManager.getConnection("??","arif","arif");
i have user arif in my database and my computer name is "ABCD"
Please help me,
i m thanksfull,
onlyforjava.Thanks i try it,
url = "jdbc:oracle:thin:@ABCD:1521:" + sid;
connection = DriverManager.getConnection(url,"arif","arif");
but after that i got exception,
java.sql.SQLException: Protocol violation
Please help me,
i m thanksfull.
onlyforjava. -
Is there a way to connect to a MYSQL database without using the JDBC driver?
Like if I wanted to connect to the database using php in the java file like so:
<?
/*--------- DATABASE CONNECTION INFO---------*/
$hostname="localhost";
$mysql_login="myusername";
$mysql_password="mypassword";
$database="mydatabase";
// connect to the database server
if (!($db = mysql_pconnect($hostname, $mysql_login , $mysql_password))){
die("Can't connect to database server.");
}else{
// select a database
if (!(mysql_select_db("$database",$db))){
die("Can't connect to database.");
?> and then write the code to a table using java. Is that a possibility? -
Calling Stored Procedure without JDBC-Adapter
Hallo,
as it is not possible calling Stored Procedures with the parameter Typ Record in Oracle my question: It is possible connecting to DB using native java-code for example in Mapping?
Thanks in advance,
FrankHi Frank,
Maybe you can use the DB look up using the JDBC adapter in your mapping.
Just check this blog for the same,
/people/siva.maranani/blog/2005/08/23/lookup146s-in-xi-made-simpler
As for calling an Oracle Strored Procedure, it is possible using a RECEIVER JDBC adapter, but not a SENDER JDBC adapter.
<i> import the jdbc-driver (oracle) in an archive in Designer.</i>
Also, this imported archive should be under any Namespace, but, it should be in the same SWCV as the one in which the mapping is being executed.
Regards,
Bhavesh -
Executing DB2 API (without JDBC)
I'm trying to call a DB2 API (e.g. sqlbgtss) from a Java program. I do not want to use JDBC.
Can someone help me?You probably have to write your own bridge in JNI then.
-
Use of UserTransaction without XAConnextion
Hi,
I'm using a UserTransaction. Between my begin() and commit(), I use 2 differents javax.sql.Connection.
Everything works fine when I commit or rollback.
That is the problem. I don't understand why it functions because I read in JTA specifications that I had tu use XAConnections ???
Thanks in advance.
Fred.The iPhone includes a Notes application, but includes no word processor or spreadsheet application. You can view word, excel, and powerpoint files sent as email attachments from within the received message, but the documents cannot be edited and/or new such documents created.
Some 3rd party applications don't require internet access, but you will need a wi-fi connection or cellular reception to access the 3rd party applications that do require internet access, and the same for the applications included with the iPhone. -
JDBC XMLType Insert/Update Performance
I am writing a backend Java EE application that inserts or updates XML documents into a table backed by XMLType. I'm using Oracle 11.2.0.3 with associated drivers and XDK, with connections obtained from an oracle.jdbc.poo.OracleDataSource. Unfortunately, I can't get my application to perform faster than 7 transactions a second, with or without JDBC batching. I've tried several different table structures; here are the two that have shown the most promise:
CREATE TABLE mrbook_raw
id RAW(16),
created_date TIMESTAMP,
last_modified_ts TIMESTAMP,
bk_typ_cd VARCHAR2(16),
bk_invt XMLType,
PRIMARY KEY(id),
FOREIGN KEY (id) REFERENCES mrbook(id)
) XMLTYPE COLUMN bk_invt ELEMENT "http://www.mrbook.com/BookData/Vers1#BK_INVT";
--Also tried the below...
CREATE TABLE book_master OF XMLTYPE
XMLTYPE STORE AS SECUREFILE BINARY XML
VIRTUAL COLUMNS
isbn_nbr AS ( XmlCast(
XmlQuery('declare namespace plh="http://www.mrbook.com/BookData/Vers1/Header";
declare namespace bk_invt="www.mrbook.com/BookData/Vers1/InventoryData";
/bk_invt:BK_INVT/plh:HDR/plh:ISBN_NBR'
PASSING object_value RETURNING CONTENT) AS VARCHAR2(64)) ),
book_id AS ( XmlCast(
XmlQuery('declare namespace plh="http://www.mrbook.com/BookData/Vers1/Header";
declare namespace invtdata="http://www.mrbook.com/BookData/Vers1/InventoryData";
/bk_invt:BK_INVT/plh:HDR/plh:BOOK_ID'
PASSING object_value RETURNING CONTENT) AS VARCHAR2(64)) )
Here is the code that inserts into the first table:
private static final String INS_MRBOOK_RAW =
"INSERT INTO MRBOOK_RAW " +
"(id, bk_invt, last_modified_ts, created_date) " +
"VALUES (?, ?, ?, ?)";
private static final String UPD_MRBOOK_RAW =
"UPDATE MRBOOK_RAW " +
"SET " +
"bk_invt = ?, " +
"last_modified_ts = ? " +
"WHERE id = ?";
protected void updateBookRaw(BookRecord record, Connection con)
PreparedStatement stmt = null;
SQLXML sqlxml = null;
Timestamp now = new Timestamp(System.currentTimeMillis());
try
stmt = con.prepareStatement(UPD_MRBOOK_RAW);
sqlxml = con.createSQLXML();
DOMResult result = sqlxml.setResult(DOMResult.class);
result.setNode(record.getExistingInvtData());
stmt.setSQLXML(1, sqlxml);
stmt.setTimestamp(2, now);
stmt.setBytes(3, record.getId());
stmt.executeUpdate();
catch(SQLException e)
throw new RuntimeException(e);
finally
if(sqlxml != null)
try
sqlxml.free();
catch(SQLException e)
log.error("Unable to free SQLXML!", e);
if(stmt != null)
try
stmt.close();
catch(SQLException e)
log.error("Unable to close statement!", e);
protected void insertBookRaw(BookRecord record, Connection con)
PreparedStatement stmt = null;
SQLXML sqlxml = null;
Timestamp now = new Timestamp(System.currentTimeMillis());
XMLDocument bookDoc = parser.getInvtDataDoc(record.getNewBook());
try
stmt = con.prepareStatement(INS_MRBOOK_RAW);
sqlxml = con.createSQLXML();
DOMResult domResult = sqlxml.setResult(DOMResult.class);
domResult.setNode(bookDoc);
stmt.setBytes(1, record.getId());
stmt.setSQLXML(2, sqlxml);
stmt.setTimestamp(3, now);
stmt.setTimestamp(4, now);
stmt.executeUpdate();
catch(SQLException e)
throw new RuntimeException(e);
finally
if(sqlxml != null)
try
sqlxml.free();
catch(SQLException e)
log.error("Unable to free SQLXML object!", e);
if(stmt != null)
try
stmt.close();
catch(SQLException e)
log.error("Unable to close statement!", e);
I've tried every storage method possible; CLOBs, Binary XMLType, and structured storage, but I just cannot get the application to go faster than 7 records/second.
I understand that this may or may not be an XMLType question, but I don't know where to start. From everything above, it looks like I should be getting good performance inserting and updating XMLType records; and I do indeed get pretty good performance from retrieval, but not from insert or update. Does anyone have any suggestions on what I might try or a reference I might look at to start?Perhaps a more specific question... should I use PreparedStatements with SQLXML or should I use the OracleXMLSave class? Are SQLXML types batchable under Oracle?
-
NamingEnumeration ne = initialContext.list("jdbc/");
I can use java code to search datasource. However, some datasources are created by ant. These datasources' JNDI name without jdbc/
How to find all datasource using java?I use ant script to create datasource and need to use java to collect all datasource name. However, I copy the code of at thread : How to connect weblogic using java
The problem is that the datasource created by ant script do not contain JNDI name in their *.xml (E:\Jdeveloper_11120\user_projects\domains\DSdomain\config\jdbc). Their JNDI name in the xml is empty but in the weblogic console is same as datasource name. I can use java code to get all datasource if they are created at weblogic console. This is because their JNDI name at the xml file is not empty.
If I use NamingEnumeration ne = initialContext.list("jdbc/"); I can get all datasource whose JNDI name start with jdbc/ (JNDI name in the xml is not empty)
If I use NamingEnumeration ne = initialContext.list(""); I can get all datasource whose JNDI name without jdbc/ (JNDI name in the xml is not empty)
If the JNDI name in xml file is empty, I do not know how to get datasource name.
Therefore, I need to use java code to get all datasource name even if their JNDI name is empty at their xml file.
------------------build.xml-------------------------------
<?xml version="1.0" ?>
<project name="deploy" default="makeDataSource" basedir=".">
<property name="wls.username" value="weblogic" />
<property name="wls.password" value="welcome1" />
<property name="wls.url" value="t3://localhost:7001" />
<property name="wls.targetServer" value="AdminServer" />
<property name="wls.domainName" value="SOAdomain5" />
<!--<property name="database.url" value="jdbc:pointbase:server://localhost:9092/demo" />-->
<property name="database.url" value="jdbc:oracle:thin:@localhost:1521:orcl"/>
<!--<property name="database.driver" value="com.pointbase.jdbc.jdbcUniversalDriver" />-->
<property name="database.driver" value="oracle.jdbc.xa.client.OracleXADataSource"/>
<property name="database.user" value="dstest" />
<property name="database.password" value="dstest" />
<property name="weblogic.jar" value="E:\Jdeveloper_11115\wlserver_10.3\server\lib" />
<echo message="${weblogic.jar}\weblogic.jar"/>
<taskdef name="wldeploy" classname="weblogic.ant.taskdefs.management.WLDeploy">
<classpath>
<pathelement location="${weblogic.jar}\weblogic.jar"/>
</classpath>
</taskdef>
<taskdef name="wlconfig" classname="weblogic.ant.taskdefs.management.WLConfig">
<classpath>
<pathelement location="${weblogic.jar}\weblogic.jar"/>
</classpath>
</taskdef>
<target name="makeDataSource">
<wlconfig username="${wls.username}" password="${wls.password}" url="${wls.url}">
<query domain="${wls.domainName}" type="Server" name="${wls.targetServer}" property="x" />
<create type="JDBCConnectionPool" name="TestDS">
<set attribute="CapacityIncrement" value="1"/>
<set attribute="DriverName" value="${database.driver}"/>
<set attribute="InitialCapacity" value="1"/>
<set attribute="MaxCapacity" value="10"/>
<set attribute="Password" value="${database.password}"/>
<set attribute="Properties" value="user=${database.user}"/>
<set attribute="RefreshMinutes" value="0"/>
<set attribute="ShrinkPeriodMinutes" value="15"/>
<set attribute="ShrinkingEnabled" value="true"/>
<set attribute="TestConnectionsOnRelease" value="false"/>
<set attribute="TestConnectionsOnReserve" value="true"/>
<set attribute="TestTableName" value="SYSTABLES"/>
<set attribute="URL" value="${database.url}"/>
<set attribute="Targets" value="${x}" />
</create>
<create type="JDBCDataSource" name="TestDS" >
<set attribute="JNDIName" value="jdbc/TestDS"/>
<set attribute="PoolName" value="TestDS"/>
<set attribute="Targets" value="${x}" />
</create>
</wlconfig>
</target>
</project>
-----------------------datasource without JNDI name---------------------------
<?xml version='1.0' encoding='UTF-8'?>
<jdbc-data-source xmlns="http://xmlns.oracle.com/weblogic/jdbc-data-source" xmlns:sec="http://xmlns.oracle.com/weblogic/security" xmlns:wls="http://xmlns.oracle.com/weblogic/security/wls" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.oracle.com/weblogic/jdbc-data-source http://xmlns.oracle.com/weblogic/jdbc-data-source/1.0/jdbc-data-source.xsd">
<name>a2</name>
<internal-properties>
<property>
<name>LegacyType</name>
<value>1</value>
</property>
<property>
<name>TestConnectionsOnRelease</name>
<value>false</value>
</property>
</internal-properties>
<jdbc-driver-params>
<url>jdbc:oracle:thin:@localhost:1521:orcl</url>
<driver-name>oracle.jdbc.xa.client.OracleXADataSource</driver-name>
<properties>
<property>
<name>user</name>
<value>hr</value>
</property>
</properties>
<password-encrypted>{AES}jpQzVQpbfwSW8Lq4lu7h7eqAMNClQg9ILrCxpESBaCA=</password-encrypted>
</jdbc-driver-params>
<jdbc-connection-pool-params>
<initial-capacity>1</initial-capacity>
<max-capacity>10</max-capacity>
<capacity-increment>1</capacity-increment>
<shrink-frequency-seconds>900</shrink-frequency-seconds>
<test-connections-on-reserve>true</test-connections-on-reserve>
<test-table-name>SYSTABLES</test-table-name>
</jdbc-connection-pool-params>
</jdbc-data-source>
------------------normal datasource xml file: this datasource is created at weblogic console------------------------------
<?xml version='1.0' encoding='UTF-8'?>
<jdbc-data-source xmlns="http://xmlns.oracle.com/weblogic/jdbc-data-source" xmlns:sec="http://xmlns.oracle.com/weblogic/security" xmlns:wls="http://xmlns.oracle.com/weblogic/security/wls" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.oracle.com/weblogic/jdbc-data-source http://xmlns.oracle.com/weblogic/jdbc-data-source/1.0/jdbc-data-source.xsd">
<name>demo</name>
<jdbc-driver-params>
<url>jdbc:oracle:thin:@localhost:1521:orcl</url>
<driver-name>oracle.jdbc.xa.client.OracleXADataSource</driver-name>
<properties>
<property>
<name>user</name>
<value>hr</value>
</property>
</properties>
<password-encrypted>{AES}w7Z22c+GQxJHgUNeTyR8DwJ0hQjWF+n4TiyBNO1RZ38=</password-encrypted>
</jdbc-driver-params>
<jdbc-connection-pool-params>
<test-table-name>SQL SELECT 1 FROM DUAL</test-table-name>
</jdbc-connection-pool-params>
<jdbc-data-source-params>
<jndi-name>jdbc/demo</jndi-name>
<global-transactions-protocol>TwoPhaseCommit</global-transactions-protocol>
</jdbc-data-source-params>
</jdbc-data-source> -
JDBC help needed ; java.lang.NoClassDefFoundError:test1
hi, everyone, i had a problem when i run my own app to connect javadb in embedded mode
i ve added the ~/javadb/lib/derby.jar to CLASSPATH
and ~/javadb/lib/derby.jar:~/javadb/lib/derbytools.jar to DERBY_HOME
but there is a problem said my own application class cannot be found.
here is my code:
import java.sql.*;
class test1
public static void main (String args [])
throws SQLException
try {
Class.forName("org.apache.derby.jdbc.EmbeddedDriver");
} catch (Exception e) {
System.out.println("ERROR: failed to load javadb JDBC driver.");
e.printStackTrace();
return;
Connection conn = DriverManager.getConnection("jdbc:derby:testdb");
try{
Statement stmt1 = conn.createStatement();
ResultSet rset1 = stmt1.executeQuery( "SELECT * FROM PART" );
long counter1 = 0;
double price1;
while ( rset1.next() )
price1 = rset1.getDouble(8);
if (price1 == 1306.4)
counter1++;
System.out.println( counter1 );
stmt1.executeQuery("SHUTDOWN");
conn.close();
catch (SQLException e )
String errmsg = e.getMessage();
System.out.println( errmsg );
}and i ve followed one Derby JDBC tutorial on the internet,
* AutoLoadJdbcDriver.java
* Copyright (c) 2007 by Dr. Herong Yang. All rights reserved.
import java.sql.*;
import java.util.*;
public class AutoLoadJdbcDriver {
public static void main(String [] args) {
Connection con = null;
try {
listDrivers();
// Find the driver for a given URL
Driver driverClass = (Driver) DriverManager.getDriver(
"jdbc:derby://somehost/somedb");
System.out.println("\nDriver for jdbc:derby://somehost/somedb");
System.out.println(" "+driverClass.getClass().getName());
listDrivers();
} catch (Exception e) {
System.err.println("Exception: "+e.getMessage());
private static void listDrivers() {
Enumeration driverList = DriverManager.getDrivers();
System.out.println("\nList of drivers:");
while (driverList.hasMoreElements()) {
Driver driverClass = (Driver) driverList.nextElement();
System.out.println(" "+driverClass.getClass().getName());
The output below confirms that the DriverManager class is able to load any JDBC driver classes as long as their JAR files are included in the classpath.
C:\>javac AutoLoadJdbcDriver.java
C:\>java -cp .;\local\javadb\lib\derbyclient.jar AutoLoadJdbcDriver
List of drivers:
sun.jdbc.odbc.JdbcOdbcDriver
org.apache.derby.jdbc.ClientDriver
Driver for jdbc:derby://somehost/somedb
org.apache.derby.jdbc.ClientDriver
List of drivers:
sun.jdbc.odbc.JdbcOdbcDriver
org.apache.derby.jdbc.ClientDriver
but on my machine , it keep telling me the massage
Exception in thread "main" java.lang.NoClassDefFoundError: SimpleApp
Exception in thread "main" java.lang.NoClassDefFoundError: test1
Exception in thread "main" java.lang.NoClassDefFoundError: AutoLoadJdbcDriver
the ij works well
and the other java app(without jdbc) works well.
anybody can help me to solve this problem?
Edited by: Xiao on Jan 18, 2008 6:19 PMbut on my machine , it keep telling me the massage
Exception in thread "main" java.lang.NoClassDefFoundError: SimpleApp
Exception in thread "main" java.lang.NoClassDefFoundError: test1
Exception in thread "main" java.lang.NoClassDefFoundError: AutoLoadJdbcDriverI assume you get these messages when you try and run the three programs mentioned (SimpleApp, test1 and AutoLoadJdbcDriver).
What commands do you use to do this? What does the command line report the CLASSPATH to be (using the echo command)?
The simplest cause would be that you have the derby jar mentioned as part of CLASSPATH, but not the current directory. -
Hi Gurus there,
I'm new in JSP, I heard we can implement Web application with JSP using only http protocole (ie: without JDBC bridge).
The RDBMS is Oracle 8i,
Can you help me with this,
Thanks in advance.BTW, my laptop is win2000 professional, sp4. mem is 512mb. thanks
Maybe you are looking for
-
Importing In different DBProvider name : Urgent
Hi, I am trying to export a DataBase Provider from one Portal to another Portal environment. The case is that I want to import the exported DBprovider with a different name into the destination Portal environment.. Is this Possible to be done ... Tha
-
What do i need for windows?
What do i need to be able to run windows on my mac? Im currently on OS X 10.6
-
I keep getting error code 150340 when installing Acrobat reader.
-
ITunes v9 ruined my computer!
I HATE this program - used to love old version, but got an iPhone for Christmas, and computer told me to get latest version. So I, like a moron, did. Sadly, now I have no audio in anything; not in iTunes, Windows Media Player, from internet programs,
-
Gkbisd Unable to collect cdhash error code 100024
What is process/daemon gkbbisd ? What is cdhash? What means "error code 100024" ? One example message: 07/03/2014 9:17:24.443 PM gkbisd[246]: Unable to collect cdhash for /System/Library/CoreServices/Install in Progress.app (error code 100024) I have