Dyn-loading with newInstance() vs. static ref
Hello.
Here is code that does what I want:
Class.forName("com.mysql.jdbc.Driver").newInstance(); // load mysql/jdbc driver
Connection conn = DriverManager.getConnection("jdbc:mysql://ebi:3306/jlpt", "root", "pwd");
// conn is good-to-go
....Regarding this line:
Class.forName("com.mysql.jdbc.Driver").newInstance();as the returned value is ignored, this is, except for the classloading, a no-op?
Now, my understanding, is that any reference to a class triggers the loading of the class? If so, a static reference to "com.mysql.jdbc.Driver" should also load the jdbc/mysql driver class. However, this code fails with a "driver not found" exception:
String whatever = com.mysql.jdbc.Driver.DBNAME_PROPERTY_KEY; // why not load mysql/jdbc driver?
Connection conn = DriverManager.getConnection("jdbc:mysql://ebi:3306/jlpt", "root", "pwd");
// java.sql.SQLException: No suitable driver found for jdbc:mysql://ebi:3306/jlpt
// at java.sql.DriverManager.getConnection(DriverManager.java:602)
// at java.sql.DriverManager.getConnection(DriverManager.java:185)
....Here is how I tested that a static reference loads a class:
public class Main {
public static void main(String[] args) {
System.out.println("start");
int q = ClassA.i; // toggle this by commenting out / in
System.out.println("end");
public class ClassA {
static {
System.out.println("ClassA just loaded.");
static int i = 1;
}Dynamic classloading is difficult for me, and I hope I can learn from this. Thanks.
Edited by: rerf on Jul 9, 2010 9:05 AM
jverd wrote:
rerf wrote:
Hello.
Here is code that does what I want:
Class.forName("com.mysql.jdbc.Driver").newInstance(); // load mysql/jdbc driver
Connection conn = DriverManager.getConnection("jdbc:mysql://ebi:3306/jlpt", "root", "pwd");
// conn is good-to-go
....Regarding this line:
Class.forName("com.mysql.jdbc.Driver").newInstance();as the returned value is ignored, this is, except for the classloading, a no-op?JDBC drivers are supposed to have a static initializer block so that when the class is loaded, it registers itself with DriverManager. That's why we do the explicit Class.forName(). Note that the newInstance() is unnecessary.
Now, my understanding, is that any reference to a class triggers the loading of the class? If so, a static reference to "com.mysql.jdbc.Driver" should also load the jdbc/mysql driver class. However, this code fails with a "driver not found" exception:
String whatever = com.mysql.jdbc.Driver.DBNAME_PROPERTY_KEY; // why not load mysql/jdbc driver?
Connection conn = DriverManager.getConnection("jdbc:mysql://hiroo:3306/jlpt", "root", "rpp");
// java.sql.SQLException: No suitable driver found for jdbc:mysql://ebi:3306/jlpt
// at java.sql.DriverManager.getConnection(DriverManager.java:602)
// at java.sql.DriverManager.getConnection(DriverManager.java:185)
I don't know. Just as a guess, it might be that the "whatever" line is getting optimized away since you never use "whatever." Try printing it out and see if that changes things. I would have expected that to cause the class to load as well.this runs ok:
String whatever = com.mysql.jdbc.Driver.DBNAME_PROPERTY_KEY;
// Connection conn = DriverManager.getConnection("jdbc:mysql://ebi:3306/jlpt", "root", "pwd");
System.out.println("whatever --> " + whatever);
....this still fails with: "java.sql.SQLException: No suitable driver found"
String whatever = com.mysql.jdbc.Driver.DBNAME_PROPERTY_KEY;
Connection conn = DriverManager.getConnection("jdbc:mysql://ebi:3306/jlpt", "root", "pwd");
System.out.println("whatever --> " + whatever);
// java.sql.SQLException: No suitable driver found for jdbc:mysql://ebi:3306/jlpt
// at java.sql.DriverManager.getConnection(DriverManager.java:602)
// at java.sql.DriverManager.getConnection(DriverManager.java:185)
// at kdata.DenJ.xtract(DenJ.java:85)
// at kdata.Main.main(Main.java:13)
.... Anyway, I am ok. Thanks for your time.
Similar Messages
-
Hi,
Above is a code that to retrieve or get info to database and the output put it in the Jtree Structure. I not hav colpiler error, but a run time just get a model that it not relation whith a model that database structure.
The code is very simple (i expect)!.
Can you say me what is my error.
Thank for advance
Pedro Salfatte
import java.sql.*;
import java.util.*;
import javax.swing.*;
import javax.swing.tree.*;
public class chequeosBase extends JTree
Connection con = null;
int iRowCount = 0;
Statement stmt = null;
String sDriver="sun.jdbc.odbc.JdbcOdbcDriver";
//String sDriver = "oracle.jdbc.oracledriver";
String sURL =
"jdbc:odbc:oracle";
//"jdbc:oracle:thin:@192.168.8.73:1521:pesp;create=true";
String sUsername = "system";
String sPassword = "manager";
void connectBase(){
try // Attempt to load the JDBC driver
{ // with newInstance
// Class.forName("sun.jdbc.odbc.Jdbcodbcriver");
//sun.jdbc.odbc.JdbcOdbcDriver
Class.forName(sDriver);
//.newInstance();
catch( Exception e ) // error
System.err.println( e.getMessage());
System.err.println(
"Failed to load current driver.");
return;
} // end catch
try
con = DriverManager.getConnection ( sURL,
sUsername,
sPassword);
stmt = con.createStatement();
catch ( Exception e)
System.err.println( "problems connecting to " +
sURL + ":" );
System.err.println( e.getMessage() );
if( con != null)
try { con.close(); }
catch( Exception e2 ) {}
return;
} // end catch
// to allow the program to be run more than once,
// attempt to remove the table from the database
try {
// String query = "SELECT ENTRY,CUSTOMER, DOW, CUPS, TYPE FROM SCOTT.JJJJDATA";
String query = "SELECT TIPO,TIPODESC, MAQUINA, MOBREFANT,INSTANCIA,VERSION FROM MONITOR.INSTANCIA";
ResultSet result = stmt.executeQuery(query);
if (result.next()){
DefaultMutableTreeNode rootNode=new DefaultMutableTreeNode("BD_AGROSUPER");
DefaultMutableTreeNode Serv=new DefaultMutableTreeNode(result.getString("TIPODESC"));
DefaultMutableTreeNode Maq=new DefaultMutableTreeNode(result.getString("MAQUINA"));
DefaultMutableTreeNode Nombre=new DefaultMutableTreeNode(result.getString("MOBREFANT"));
rootNode.add(Serv);
Serv.add(Maq);
Maq.add(Nombre);
this.setModel(new DefaultTreeModel(rootNode));
// String s = result.getString("TIPODESC");
// System.out.println(s);
// System.out.println("PORAQUI");
catch (Exception f){System.err.println( f.getMessage());}
finally
try { stmt.close(); }
catch( Exception e ) {}
try { con.close(); }
catch( Exception e ) {}
} // end finally clause
public static void main(String[] args)
// this.setModel(new DefaultTreeModel(rootNode));
JFrame f = new JFrame("CHEQUEO BASES AGROSUPER");
chequeosBase t = new chequeosBase();
t.putClientProperty("JTree.lineStyle", "Angled");
t.expandRow(0);
f.getContentPane().add(new JScrollPane(t));
f.setSize(300, 300);
f.setVisible(true);d'oh
//what i have
root
level1a
level1b
level1c
//what i want
root
level1a
level2a
level2b
level2c
level1b
level2a
level2b
level1c
level2asorry!
no replies? is this an incredibly stoopid thing to ask or do people just not do this? or.. ?
Message was edited by: txjump
txjump -
FB Debug application loaded with SWFLoader
I am fairly new to flex builder, I am working on a fairly
large project that has many pages. To reduce the application sizes,
I have created seperate applications for each type of user. The
login page then loads the appropiate application useing SWFLoader.
When I try to debug the application by setting a breakpoint within
my application and start the login page, my breakpoint never
breaks. Does anyone know anything about this, or how I would debug
an application loaded this way. Just a note, I cannot run the
loaded application without the login applicaiton being loaded
first. The login app contains data that the secondary application
needs.Most likely the issue here is that the SWF that you are
loading with the <SWFLoader> tag was not built for debugging.
E.g. say you have a project called MyComponent, and then the
main project called MyApp. Inside MyApp.mxml you have this:
<mx:SWFLoader source="MyComponent.swf" />
And presumably you manually copied MyComponent.swf from
MyComponent/bin into the MyApp project. Well, the MyComponent
project built two versions of the SWF: MyComponent.swf, which is
the release version, and MyComponent-debug.swf, which is the debug
version.
So if you need to debug it, you'll have to copy
MyComponent-debug.swf over to the MyApp project. To get it to load
with the SWFLoader tag, you'll either need to temporarily change
the filename in the SWFLoader tag to refer to
MyComponent-debug.swf, or else rename the debug SWF to the release
filename of MyComponent.swf.
Unfortunately there is no automated workflow to have
SWFLoader detect whether it is running debug or release, and load a
different SWF. -
Help! (please I have a 1GB iPod that's loaded with music for which my computer can no longer find the original files-due to external mass storage crash during recent move. Is there a way to import iPod music back into my iTunes library on computer???
Or If there is any purchased music then you can try to transfer purchases
http://support.apple.com/kb/ht1848
If you're in the US you can reload purchased music
http://support.apple.com/kb/ht2519 -
I just installed LV2011 and one dll from my vi won't load with the error "application configuration is incorrect", which is Windows lingo for "missing package dependencies". All the computers at my company with 2010 loaded seem to do OK. When I do a Dependencies Walk I get missing Visual C debug dll's missing plus IEshims and wer which both have a whole tree of dependencies missing on my machine. The Windows install is the same "Windows XP version 2002 Service Pack 3" on my PC and the working PC's. So I'm thinking I have to uninstall 2011 and go back to 2010. Is this correct? Those VC debug dll's were installed on the machines with 2010 in them but were not installed in mine.
I've heard the advice to recompile the dll with debug turned off but I don't have access to the source code.
Thanks in advance.u87 wrote:
Thanks for the reply. This at least tells me that going back to LV2010 is not likely to solve the problem. The missing dll's are:
MFC90D.dll
MSVCR90D.dll
IESHMS.dll
WER.dll
And, once again, IESHMS and WER have other dependencies. So perhaps i need to install the Visual C++ development environment.
IESHIMS.dll is an Internet Explorer DLL that gets usually delay loaded by shdocvw.dll. As delay load it can not cause DLL load errors but only runtime errors. Maybe your DLL has it as direct dependency but that is unlikely since it does not have a documented interface.
WER.dll is Windows error reporting for Vista/Win7.
MFC90D.dll is the Microsoft Foundation classes and MSVCR90D.dll is the MS C runtime library, both as debug variant.
So all the DLLs you mention are actually MS DLLs! You haven't identified the DLL that you try to access in LabVIEW that causes these error messages. IESHIMS and WER are usually delay loaded by any component that needs it and should not likely be used by non MS code.
What is the DLL you try to load into LabVIEW and by whom? Get the provider of that DLL to provide you a non Debug build of the DLL. Installing Visual C on all the machines just to make the DLL load is not a solution, besides that it is likely not legal since I doubt you have that many licenses.
Rolf Kalbermatter
CIT Engineering Netherlands
a division of Test & Measurement Solutions -
Cube loaded with data, but unavailable in the query
Hello everyone,
Someone can help me?
I created a new Cube CO-PA for the year 2010, and loaded with data this year. To make sure that the data were correct did a ListCube, with all the filter equal to the query, and indeed the data is loaded properly for this year. And when i run the query with data from the years 2008 and 2009 show me data in my report, but when I run the query for 2010, the query displays an error message saying that "no data".
How is it possible to have the correct data in the Cube, and i can not view the data in the query?
Note: The request in the cube is available to report
Thank you all,
Greetings,
Maria João
30-Março 2010Hello,
I was in trouble because I had not selected the key figures in the multicube : S
After selecting the key figures, I ran the query and it had data.
Thank you for your help.
Sincerely,
Maria Joã -
my macbook is loaded with microsoft word for macs and every time I try and open the program I get an error reading and it will not open. This is what it says:
The application Microsof Word quit eunexpectedly. Powerpoint and the other applications still respond!The joys of Microsoft!
Maybe the preferences file is corrupted. You should be able to find the Word preferences file in the folder:
your user name/Library/Preferences
Its name is com.microsoft.Word.plist
I suggest you drag this another folder and try Word again.
If that doesn't work then you might find clearing the cache files will fix the problem. You can do this manually but I never bother. Instead I use a program like Snow Leopard Cache Cleaner (shareware) or Onyx (free). These programs do lots of other maintenance jobs so it's worth having at least one of them.
Bob -
The problem and solution is pretty simple, I just want to know if anyone has tried this before. I have a brand new Macbook Pro that I bought more or less for the sole purpose of having a more powerful machine to run AVID Media Composer on. AVID is only compatible up to OS version 10.6.7 at the moment, and the machine I got was pre-loaded with Lion, 10.7....So I look at the support documentation Apple provides, and notice that in the nifty little chart they have, the latest line of Macbook Pros out there (early 2011) originally had version 10.6.6, so I'm assuming that's the previous version I can't downgrade past.
To revert back to Snow Leopard, however, I need to install it from the DVD which has version 10.6.3 on it, and then upgrade to any version between Snow Leopard 10.6.6 and Lion 10.7. In theory this could work, the only problem being that for a brief time between installing Snow Leopard and updating to the version of it that I need, the computer will have version 10.6.3 on it.
Now I'm pretty sure if the only thing I do on the computer is immediately update to a safe-to-use version, there will be no problems. However, if the machine's hardware is so terribly non-backwards compatible with the Snow Leopard OS, I may do all this backing up and reverting and not even be able to start the computer once I get the old install on it. Before I just go ahead and try this for myself, I was wondering if anyone else has, and more importantly, have you had any success?Hi r,
EDIT: disregard my post. Waiting for that disc is a far better option.
I hope w won't mind if I add a thought here:
rmo348 wrote:
Now I don't mind if some drivers are messed up and resolution is all funky when I install 10.6.3 on it, I just need to know if it'll be functional to the point where I can run the 10.6.6 update dmg. Once I update to 10.6.6 everything should work fine.
Or could I install 10.6.3, have the 10.6.6 update burned to a disc, and boot straight from that? This is my first Mac so I'm not sure what little tricks work or not.
Your first idea may work; the only way to know for sure is to try it. If you do, make sure you download and run the Combo update for 10.6.7 or 10.6.8. There can be different versions of a point update, those which are available for download, and those which ship on Macs, so you want to install one beyond that which shipped with some of the new MBPs.
If the MBP won't boot to 10.6.3, something else to try is installing it to an external HD, then installing the 10.6.7 update on it, clone it to the MPB's internal HD, and run the 10.6.7 or 10.6.8 Combo update on it. -
Can i install snow leopard on my new macbook pro which came loaded with Lion?
My new MBP came loaded with Lion. Can i install S.L. on it?
Don't install a version of Mac OS X earlier than what came with your Mac
-
I have an ipod classic loaded with songs from my old computer that were put on my library from cd's. can I transfer those songs onto my new computer from my ipod or do I need to re-record them to my library on disc at a time?
See this excellent user tip from another forum member turingtest2 outlining the different methods and software available to help you copy content from your iPod back to your PC and into iTunes.
Recovering your iTunes library from your iPod or iOS device
B-rock -
I bought a brand new Mac 27" desktop that came loaded with Adobe CS6. Everything worked like a charm until the hard drive, 1Tb, developed a bad sector and the Apple Store reinstalled a new one as I had extended warranty with them. They recycled the drive immediately (like a fool I didn't ask for it back to get the data off it.) But luckily I have all my data on CrashPlan. I downloaded it and it worked great except I downloaded it to the desktop and not the original location so it got squirrely. I also have an external 1.5Tb drive that I wanted to make bootable so I installed Mavericks 10.9.3 . I then went ahead and installed it on the newly installed drive too.
I think that because I have a new drive Adobe thinks I have a news computer. I bought the 27" Mac brand new from Ebay and it came loaded with software, including CS6. I have a serial number for CS6 but Adobe said it wasn't valid. (I have owned CS2, CS4 and now CS6 which came preloaded onto the Mac by the seller who told me that the software was registered to the Mac???
I am going to re-download the backup but this time to the original location (I still don't think it will work with Adobe. What can I do about this?
iMac 27-inch, Late 2012
Processor 3.2 GHz Intel Core i5
Memory 32 GB 1600 MHz DDR3
Graphics NVIDIA GeForce GTX 675MX 1024 MB
Software OS X 10.9.3 (13D65)@You need to contact Adobe Support either by chat or via phone when you have serial number and activation issues.
Here is a link to a page with options to help make contact:
http://www.adobe.com/support/download-install/supportinfo/ -
Button in Bex Analyser 7.0 - problem with setting up Static Parameters
Hello,
I know a similar problem has been discussed here already, but I am still having problems with setting up Static Parameters of my Button in BEx Analyser 7.0, so that I can pass Variable values from that button to my query.
This is what I do - in Static Parameters of my Button I set the following values:
Name Index Value
DATA_PROVIDER 0 DP_1
CMD 0 PROCESS_VARIABLES
SUBCMD 0 VAR_SUBMIT
VAR_NAME 0 0RMA_FIP
VAR_VALUE 0 004/2010
As a result, I would like the value 004/2010 to be passed to variable 0RMA_FIP (which is mandatory) and the query to be executed with that value. For some reason, however, the value is not passed correctly, and instead the variable is filled with a blank or not filled at all, and I am getting a message "Specifiy value for variable Fiscal year/period". What do I do wrong?
Just to give you a broader picture - I would like to later use this logic to pass more than one variables into a query, including a hierarchy node, and read the values from an Excel worksheet - however, after many attempts to do so, I started playing with just one variable to figure out what the problem was.
I have already seen the following two threads and SAP notes on passing variable values from the button:
Re: Button in BEx Analyzer 7.0
Re: How to set variables values via VBA.
http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/f0881371-78a1-2910-f0b8-af3e184929be?quicklink=index&overridelayout=true
Can anyone please advise?
Cheers,
ALI managed to figure it out myself!
Instead of VAR_VALUE I need to enter VAR_VALUE_EXT, and it works fine.
I will mark this thread as "answered". -
Batch loading with sdordf.jar.
Hi Guys
I have just tried a batch load with sdordf.jar.
In my first attempt there was a mistake in the n3 file.
After correcting the file and re running I now get the error.
Connecting to jdbc:oracle:thin:...........
Append mode
Copy existing data out
Just load triples into one column
Temporary table already exists!
java.sql.SQLException: ORA-00955: name is already used by an existing object
ORA-06512: at "MDSYS.SDO_RDF_INTERNAL", line 3326
ORA-06512: at "MDSYS.SDO_RDF_INTERNAL", line 3362
ORA-06512: at "MDSYS.RDF_APIS", line 786
ORA-06512: at line 1
Can anyone tell me what the name of this temporary table is, so that I can get rid of it.
Cheers
PhilHi Mellie
After having a little break I have installed the jena patch during which I had to drop the network and model created before.
I tried running a batch load as before but I still get the error message saying the temporary table already exists.
I tried the clean up routine as suggested but get the error.
SQL> exec sdo_rdf.cleanup_batch_load('researchdata')
BEGIN sdo_rdf.cleanup_batch_load('researchdata'); END;
ERROR at line 1:
ORA-13199: Batch load cleanup failed. ORA-00942: table or view does not exist
ORA-06512: at "MDSYS.MD", line 1723
ORA-06512: at "MDSYS.MDERR", line 17
ORA-06512: at "MDSYS.SDO_RDF", line 1016
ORA-06512: at "MDSYS.SDO_RDF", line 1022
ORA-06512: at line 1
I run it as mdsys as you said.
Any other suggestions?
Cheers
Phil -
Adobe photoshop elements 8 and premier elements 8 will not load with security numbers.
purchase HP computer in 2011. hard drive crashed. replaced for free by HP.
but software never reloaded on computer.
computer now works and I cannot load adobe software that was never used.
Office did load with help of computer geek today.Go into the program files (program files(x86) for a 64-bit system), find the Elements 8 folder and within that Plug-ins>ImportModules and delete the Adobe TWAIN plugin. (You may have trouble scanning directly into the editor after doing this)
-
I bought my macbook pro on August 2011 at an apple store, with the Intel i7. However mirrorring in not working with two of my Apple TVs. These Apple TVs are 2nd and 3rd generation loaded with the latest software. I can succesfully transmit from my itunes on my Macbook pro to both Apple TVs, but I can not see the airplay icon on the taskbar. Can someone help?
About AirPlay and Airplay Mirroring
AirPlay Mirroring requires a second-generation Apple TV or later, and is supported on the following Mac models: iMac (Mid 2011 or newer), Mac mini (Mid 2011 or newer), MacBook Air (Mid 2011 or newer), and MacBook Pro (Early 2011 or newer). For non-qualifying Macs you can try using Air Parrot.
Several Apple Articles Regarding AirPlay
Apple TV (2nd and 3rd gen)- How to use AirPlay Mirroring
How to set up and configure AirPort Express for AirPlay and iTunes
About AirPlay Mirroring in OS X Mountain Lion
iTunes 10- About playing music with AirPlay
Troubleshooting AirPlay and AirPlay Mirroring
Using AirPlay
Maybe you are looking for
-
While i creation of Excise invoice with this t.code J1IIN with refference to Billing document this is autometically generated the Excise invoice and while i save this document the system thowing the following eror. AT1 : Debit = 77,01 C
-
LR encountered an error when reading from its preview cache and needs to quit.
I have the 30 day trial version of Lightroom. I was able to use it for one week, but the past 1.5-2 weeks, it has been locked up and giving this error message. How do I resolve the problem? And how do I reset the 30 day free trial? I would like t
-
GR- Based IV - Goods receipt-based Invoice verification
Hi, I am trying to make a new purchase order type all equal to the standart type. I only want an exception: the GR-based IV indicator must be, by default, off. This indicator specifies that prevision has been made for goods -receipt base invoice veri
-
Macbook Pro 17" Mid 2009 Freezes completely.
I have a Macbook Pro 17" Unibody Mid 2009 2.8 Ghz 4GB Ram running OS X Lion 10.7.5 . Started noticing the issue when running Safari. Browser would lock up/ freeze. I would have to force quit. Thought it was a webpage issue and tried another browser.
-
I have photoshop elements 9 and iphoto does not show it in my advaced preferences drop down, it used to be there, how do I get it back again?