Hi guys, I followed this tutorial here to test data source. http://www.webagesolutions.com/knowledgebase/waskb/waskb001/index.html I did everything that was there on the page and now I write the following sample Servlet as shown in the example with my own datasource name as import java.io.IOException; import java.sql.SQLException; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; public class DataSourceTesting extends HttpServlet { public void doGet(HttpServletRequest ... |
|
|
|
|
|
|
|
I'm using a DataSource to allow for pooling MySQL5 connection via Tomcat 6. I have a ServletContextListener and I'm wondering what the standard way of dealing with 'cleanup' is. Here's what I have as a first attempt. Suggestion? Thanks all: /* Remove DataSource and Logger attributes */ public void contextDestroyed (ServletContextEvent sce) { Logger logger = Logger)sce.getServletContext().getAttribute("dispatchLogger"); try { logger.logp(Level.INFO,"DBCPoolingListener", "contextDestroyed(ServletContextEven ... |
Hi, I have a question.I use datasource.getConnection() to get the connection as below. My question is does getConnection() have to be synchronized? Won't the datasource manage the connections in the pool. public Connection static synchronized getConnection(){ Connection conn = null; try{ DataSource dataSource = serviceLocator.getInstance().getDataSource (dataSourceName); conn = dataSource.getConnection(); } catch(Exception ex) { //do something here } return conn; } |
I have concerns over passing DataSource object in a method. Rather, can the client (ClassA) create a datasource object and pass it to other method (in a classB)? Thanks in advance, Example: public classA { public static List getData() { return new ClassB().getData(createDataSource()); } private static DataSource c{ //Create a datasource object (ds) based on the //database connection parameters return ds ... |
I need a nudge or a shove in the right direction. I'm a Java newbie, but need some architecture advice on working with multiple db's in a servlet or J2EE situation....so I can narrow my vision/world a little and prevent getting overwhelmed. My challenge in a Nutshell. I have a commercial product that uses Oracle. This product has one database for ... |
HI Am using Oc4J datasource and three different application were using that. Is there any limitation for datasource say for example 100 connections or 200 connections. I know that it will reuse the connections. But what is the maximum no. of connections can a datasource hold ??. My application is MDB. So 3 MDBs may use some 1500 connections at a ... |
|
|
|
|
|
Hi, Our application has an requirement of handling failover/overload in backend access components. (Any suggestions other than mentioned below to handle runtime FAILURE/SUSPEND/OVERLOAD OF DATASOURCE is appreciated) since i am a newbie in JDBC and datasource i need some clarifications on jdbc datasource. i have a datasource DS1 associated with connectionpool CP1 , max connection capacity - 50 if i create ... |
Thanks for the response scott. This is to implement the proxy design pattern which is my cleint requirement. I've to proceed like this only for the SQLServerDataSource. OK, if i do testdatasource extends SQLserverDataSource i can achieve want i want.(setting the applicationname). But i'm having problem in accessing the datasource as specified earlier. Which is the retrieval of sqlserverdatasource from appserver's ... |
public class DBBoard { static DataSource dtsrc; static Context envCtx; public static Connection getConnection(){ Connection con = null; if(dtsrc==null){ getDataSource(); } try{ con = dtsrc.getConnection(); }catch(SQLException es){ es.printStackTrace(); } return con; } public static void getDataSource(){ if(envCtx==null){ getEnvironmentContext(); } try{ dtsrc = (DataSource) envCtx.lookup("jdbc/someDB"); }catch(NamingException ne){ ne.printStackTrace(); } } public static void getEnvironmentContext(){ try{ envCtx = (Context) new InitialContext().lookup("java:comp/env"); }catch(NamingException ne){ ... |
|
i want to know if i can use DataSource mechanism instead of DriverManager to connect to a MS SQL Database. I use- 1) NetBeans 6.8 2) MS SQL Database 2005 with ms sql connector for java The below is my program which compiles and runs fine but without any output. The Database tables are correct. Thanks in advance. import java.sql.Connection; import ... |
|
|
Disconnecting and reconnecting is the only way to do this. Because you have a connection pool you will not actually know if the connection is actually closed or just returned to the pool. I can't think of a reason why you would want to do this though. What is driving this requirement? |
|
Hi All, Can anyone please help me connecting a DataSource from Oracle 9i I am using Oracle 9i as DataBase and Eclipse IDE and JBoss Application Server, I am using some code in oracle-ds.xml as below DSSDEV jdbc:oracle:thin:@172.26.173.133:32200:DSSDEV begin execute immediate('ALTER SESSION SET NLS_DATE_FORMAT = ''DD.MM.YYYY'''); execute immediate('ALTER SESSION SET NLS_TIMESTAMP_FORMAT =''YYYY-MM-DD-HH24.MI.SS.FF6'''); execute immediate('ALTER SESSION SET CURRENT_SCHEMA = DSSDEVDBALS'); end; ... |
|
I made the data source static so that i wont need to do the lookup every time a request comes into my webapp and i was wondering if it would cause problems. The code checks if its null, and if it is, makes it. Two threads could make it, and I guess one would be overwritten, because its not technically a ... |
|
In other words: try { Connection conn = _ds.getConnection(); try { Statement stmt = conn.createStatement(); try { ResultSet result = stmt.executeQuery("SELECT * FROM books"); try { ... } finally { result.close(); } } finally { stmt.close(); } } finally { conn.close(); } } catch (SQLException ex) { Logger.getLogger(DataSourceExample.class.getName()).log(Level.SEVERE, null, ex); }Or, with Java 7: try (Connection conn = _ds.getConnection(); Statement stmt ... |
A datasource is typically a way for the server to manage the connection (or more likely connection pool) for you. A server has a map of datasources and other managed resources in a directory called the JNDI. You use a JNDI reference name in order to retrieve a reference to the datasource in your code. |
|
|
Hi all, I am trying to access my database using a DataSource but I am encountering a problem and have tried in vain to find a solution(code snipet and stacktrace given below). I am using websphere application server and the database is Oracle 9i. I the server running. Any help would be greatly appreciated. Thanks String dsName1 = "jdbc/UpaidPool"; // JNDI ... |
Hi all , I am using TCL file with multiple queries as input to the web services. From following statement I am getting always (like multiple tcl client ) getting single con object. conn = ServiceLookUp.getInstance().getDataSource(config). getConnection(); **** ServiceLookUp class is single tone class . ********** My Resource tag in server.xml file |
I have always used ResultSet. Now I need to scrooll through the data on JSP page. And I found out that I need to use CachedRowSet. Unfortunately, my runtime has only javax.sql.RowSet. So, I'm trying what's available I have the following code fragment 1. RowSet resSet = null; 2. resSet.setDataSourceName(DBConstants.DATA_SOURCE); When executing the second line I get "Non-application exception occurred..." Can ... |
Hi there, i am newby in application deveelopment with basic knowledge of Java programing. Here is my problem. I can connect to any database from Netbeans or Sun creator IDE. The scenario is the following: I have an oracle database; on my IDE i put a label, a text field and a static text area to display results. What is the ... |
|
|
|
|
hi, i want have a application where i will send data to mobile and recevice data from mobile to pc via bluetooth my server(PC) side is Java and Mobile side is J2ME iam using RFCOMM for communication, now i my question is wheather datasource can be used for communication if posiible please provide the articles,... |
hi i have a server code which is java runs in PC now i need to have a client code which should send the recording audio data from mobile to PC using bluetooth but i want to use datasource can it be done.. if so please post me some topics and examples Edited by: manju_hawk on Oct 17, 2008 3:18 AM ... |
OK, since I'm still getting all confused here, I'll make this a concrete example: The code above sits in test.jsp. Person A and Person B both access test.jsp at the same time on different computers. Which of the following is true: 1) Person A and Person B each have connections from THE SAME connection pool 2) Person A has 1 connection ... |
|
Hi, I'm creating pdf reports with IReport and I'd like to use JavaBean Datasource. But I want to receive two separated Bean Arrays in my Report. It seemed to me, from tutorials, that it is not possible to achieve. Is it possible instead? I'm thinking to use also subreports to receive this separated beans. Is it possible to set two different ... |
|
|
Hi. I have some problems with a JMF DataSource. I need get a byte array from the DataSource when I receive RTPStream in the end point. But in all examples the DataSource is used for creating a Player: DataSource ds = stream.getDataSource(); Player p = javax.media.Manager.createPlayer(ds); Component comp = p.getVisualComponent(); Help me anybody, please. How can I create byte array (for ... |
Hi Java application gets its data from DB in XML format. It comes in through jdbc as a clob. In java, i have a bunch of classes to where I should inject data from XML. What would be the best way to do this? I'm not very familiar with java and so all suggestions are welcome. At the moment reflection is ... |
|
|
[java] Oct 23, 2007 9:40:30 AM oracle.j2ee.rmi.RMIMessages EXCEPTION_ORIGINATES_FROM_THE_REMOTE_SERVER [java] WARNING: Exception returned by remote server: {0} [java] java.rmi.RemoteException: bindWebApp() failed!; nested exception is: [java] oracle.oc4j.admin.internal.DeployerException: [RTGSApplication:rtgs] - Unable to resolve datasource: jdbc/__default [java] at com.evermind.server.administration.DefaultApplicationServerAdministrator.bindWebApp(DefaultApplicationServerAdministrator.java:420) [java] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [java] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) [java] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [java] at java.lang.reflect.Method.invoke(Method.java:585) [java] at com.evermind.server.rmi.RmiMethodCall.run(RmiMethodCall.java:53) [java] at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:303) [java] at java.lang.Thread.run(Thread.java:595) [java] Caused by: oracle.oc4j.admin.internal.DeployerException: ... |
Guys, Please help me on this ! I have created a pluin project( BIRT ODA API) using elipse and i have placed it in plug-in folder of BIRT RCP Desighner. When i try create a new data source i am getting the below exception and the jars are available in plugin folders : org.eclipse.datatools.connectivity.oda.consumer.helper.OdaHelperException: Unable to create the ODA driver's connection ... |
|
|
|
Hi, I am trying to find examples on how to use the javax.activation. classes datasource and datahandler. What I am trying to do is allow a user to specify a url. Depending on whats specified on the url, I would like my application to seek out a custom written datahandler to process it. For example, the URL could be the filepath ... |
Well, that's one way of getting the DataSource, using the ServiceLocator pattern. But there are other ways to do it too. I think the article is trying to describe the service locator pattern and is using the data source as an example. If you know the DS is bound to JNDI, the service locator is a superfluous layer of abstraction. |
Not sure what you're looking to do, but, one possible problem is, you are returning true if there's an excpetion, which is not the best approach. It would probably be easier if you just put that code into what ever method executes the sql command- check to see if the connection is non-null and available. If not, re-initialize it. |
Can anyone help me to convert one of these javax.sound.sampled.AudioInputStream java.io.InputStream javax.sound.sampled.DataLine javax.sound.sampled.SourceDataLine to one of these javax.media.protocol.DataSource javax.media.bean.playerbean.MediaPlayer javax.media.Manager javax.media.Player or any other Player in any other package that has a good set of controls like stop, play, seek and volume for MPEG3 audio The obvious answer is write the stream to a file first and then use a MediaLocator. ... |
hi thanks for the information.I used the url object to pass the url.thats fine.But when i tried to send an email ,it is showing the email is sent but i dint get the email.But when i used FileDataSource instead of URLDataSource it is just sending the code as an attachment .What might be the problem? |