How to write a class loader to solve the class confliction in rt.jar?

Hello guys:
The weblogic.jar has the javax.management.*, it is conflict with rt.jar's
I want to use JMX 1.0 to communicate with weblogic 8.1. The client should be run in the Java 1.5
It throw
java.io.InvalidClassException: javax.management.ObjectName; local class incompatible:
stream classdesc serialVersionUID = -5467795090068647408, local class serialVersionUID = 1081892073854801359
java.io.InvalidClassException: javax.management.ObjectName; local class incompatible:
stream classdesc serialVersionUID = -5467795090068647408, local class serialVersionUID = 1081892073854801359I know the reason is java 1.5 has JMX 1.2 in it.
So how can I program a class loader to load the weblogic.jar classes in? I have tried a lot of code, but failed.
Is there any sample here?
I want to use the JMX 1.0 in weblogic.jar at jdk1.5 run time
Thanks a lot,
Qiang

Hello guys:
The weblogic.jar has the javax.management.*, it is conflict with rt.jar's
I want to use JMX 1.0 to communicate with weblogic 8.1. The client should be run in the Java 1.5
It throw
java.io.InvalidClassException: javax.management.ObjectName; local class incompatible:
stream classdesc serialVersionUID = -5467795090068647408, local class serialVersionUID = 1081892073854801359
java.io.InvalidClassException: javax.management.ObjectName; local class incompatible:
stream classdesc serialVersionUID = -5467795090068647408, local class serialVersionUID = 1081892073854801359I know the reason is java 1.5 has JMX 1.2 in it.
So how can I program a class loader to load the weblogic.jar classes in? I have tried a lot of code, but failed.
Is there any sample here?
I want to use the JMX 1.0 in weblogic.jar at jdk1.5 run time
Thanks a lot,
Qiang

Similar Messages

  • How to improve class-loading performance for missing classes

    Hi,
    do you have any ideas how we can improve the class-loading performance on a weblogic 12c running on jrockit? We spend about 20-30 ms per request in class-loading due to the way hibernate criteria API works (it tries to load quite a lot of missing classes). The only thing I came up with was to invert the class-loading using the weblogic descriptor for those missing classes (which are actually no real classes but some parts of a generated JPQL) which does improve performance a bit.
    Thanks
    Dimo

    Hi,
    do you have any ideas how we can improve the class-loading performance on a weblogic 12c running on jrockit? We spend about 20-30 ms per request in class-loading due to the way hibernate criteria API works (it tries to load quite a lot of missing classes). The only thing I came up with was to invert the class-loading using the weblogic descriptor for those missing classes (which are actually no real classes but some parts of a generated JPQL) which does improve performance a bit.
    Thanks
    Dimo

  • How to write strings with an underline on the TOP-OF-PAGE of ALV

    How to write strings with an underline on the TOP-OF-PAGE of ALV

    if u r using classes and methods it can be done
    but if u r using normal fms and then u have to use HTML_TOP_OF_PAGE but the drawback for this it cannot be printed when the report is printed .

  • How does one call a class if  one gets the class name from a database?

    Hi,
    I'm writing an application that needs to handle different types of input file.
    Each type of input file will be handled by a different processing class.
    I plan to use a controller class that will read from a database rows that each contain a file name and processor class name such that the class can then be used to process that file:
    So on a table somewhere I might have relationships like:
    file1.csv , ProcessorClassA
    file2.csv , ProcessorClassB
    file3.csv , ProcessorClassB
    My hope is that if I need a new processor class, I will not have to change the controller class. I simply write the new class say, ProcessorClassC and put an entry in my table for:
    file4.csv , ProcessorClassC
    So, finally, the question...
    I can read in the new class name into a string but how can I employ that class or instantiate objects of that new class and use their methods.
    The rationale is that so that the controller class needs no further modifications no matter how many new processor classes are required.
    Any ideas anyone?

    A factory class? I'm all ears... or is that another
    days work...?Look e.g. here (or Google for "Factory Design Pattern"):
    http://www.exciton.cs.rice.edu/JavaResources/DesignPatterns/FactoryPattern.htm

  • Error : the class does not match the class of the persisted object

    Hi I am new to Java.. I got an exception "the class does not match the class of the persisted object for cl = java.util.Vector : __SUID = -2767605614048989439, getSUID(cl) = 1".. What it implies? I got Serialized stream and Object from Web Server.. How to resolve this Exception? I nead to Deserialize this stream...

    ArulPrabhu wrote:
    Friend... I agree with u... Every thing Ok... I am not having the option to make change on the server side... I call a webrequest for the URI - "http://www.nseindia.com/chartdata?mkttype=N&series=EQ&symbol=RPOWER&charttype=ONLINE_STOCK".. From that i got response as Serialized Object Stream... Which is the data made available to all through their applet "Chart".. But i need it for my Custom Project.. I know the Structure of class they have serialized... Is their any chance to parce Data from that Stream..
    Three words.
    You are doomed.
    Whatever you end up doing will not be serialization. It will be reverse engineering of a old (dead) format that could go all pear shaped on you when you least expect it. One of the worst problems in using a solution where you reverse engineer, try and guess hackery your way through a proprietary semi (or totally) undocumented format is that it is really impossible to test your code with any degree of certainty. Does your code actually work? Or does it only work because you haven't seen some totally unexpected (but legal for the format) format yet?
    Get the producer to produce XML instead of "serialized" data. This is a much better route for you to go down.
    If you decide to keep on your path then grab a DataInputStream and go somewhere else because you'll have to figure out the format of another languages serialized data on a place that isn't this site.

  • How to write into a private fiald from the outer world?

    Hello,
    I have just got some strange rerults and want to share them with you.
    I'm writing a bean class. Each field of the bean conforms to a column in a table of the database. The bean is filled with a record of database from database by Entity Factory and is returned to me. I have not seen the sources of the Entity Factory system. The beans are entities that have setter and getters.
    All my colegues use a standard scheme with private field (named as a column in the database) and setter/getter for it. I have deriviated from this scheme creating a virtual property; that is only setter and getter with no private field. And the Entity Factory started crushing! It cannot find the private field anymore to write data from a table into it!
    I had an experiment adding the private field with the final modifier. And what do you think I've got in effect? The entity Factory started complaining that it CANNOT SET A PRIVATE FIELD BECAUSE IT IS MARKED WITH FINAL! Removing the final has solved the problem.
    Can you beleive this story? As the system is Enterprise, I would think that application server would sublass my implementation. But the privates should be inaccessible anyway. I'm going to look into source codes tomorrow.

    As Kayaman says, you can get around the restriction described in the JLS by use of Reflection.
    Consider the following example:
    class SimpleKeyPair {
        private String privateKey = "original"; // private field
    public class ReflectionChecker {
        public static void main(String[] args) throws Exception {
            SimpleKeyPair keyPair = new SimpleKeyPair();
            Class c = keyPair.getClass();
            // get the reflected object
            Field field = c.getDeclaredField("privateKey");
            // set accessible true
            field.setAccessible(true);
            System.out.println("Value of privateKey: " + field.get(keyPair)); // prints "original"
            // modify the member varaible
            field.set(keyPair, "altered");
            System.out.println("Value of privateKey: " + field.get(keyPair)); // prints "altered"
    }

  • Java.sql.Date and java.util.Date - class loaded first in the classpath

    I had two jar files which has java.util.Date and java.sql.Date class file. i want to know whether which class is loaded first in the classpath...
    I like to change the order of loading the class at runtime...
    Is there is any way to change the order of loading of class...
    I may have different version of jar files for example xerces,xercesImpl. some of the code uses xerces ,some of the code uses xercesImpl..i had common classes.
    I like to load the class with the same name according to the order i need..
    Can we do all these in Run time ?????

    I had two jar files which has java.util.Date and
    java.sql.Date class file. i want to know whether
    which class is loaded first in the classpath...
    I like to change the order of loading the class at
    runtime...
    Is there is any way to change the order of loading of
    class...
    I may have different version of jar files for example
    xerces,xercesImpl. some of the code uses xerces ,some
    of the code uses xercesImpl..i had common classes.
    I like to load the class with the same name according
    to the order i need..
    Can we do all these in Run time ?????That is meaningless.
    The classes you are referring to are part of the Java API. Third party jars have no impact on that. And you can't change to the order because java.sql.Data is derived from java.util.Date. So the second must load before the first.
    And if you have two jar files with those classes in them (and not classes that use them) then you either should already know how to use them or you should stop trying to do whatever you are doing because it isn't going to work.

  • How to find references of a Property in the class through code? similar to 'Find All References' in Visual Studio Environment.

     Hello,
    I am trying to find a code to find all the references of the property defined in a class which is very similar to 'Find All References' function available in Visual Studio environment. But I want to have it in code during run time. How to do it?
    e.g 
    =>Property 1
    private int _Salary;
    public int Salary()
    get{return _Salary;}
    set{_Salary = value;}
    => Property 2
    private int _Bonus;
    public int Bonus()
    get{return Salary * 2;}
    Like in the above example I have two properties Salary & Bonus. Bonus is calculated from salary. As soon as I set a value to Salary, value of Bonus gets updated. 
    Similarly I want to get reference of all other properties or methods in the class or program which are affected when value of Salary is changed through code. 
    Conclusion - I want to have a method or function, so that whenever I set a value to some property in a class, I want to have a list of all the other properties(List<Property>) or methods which are affected and in which the changed property is referenced.
    Please help me to achieve this.
    Siddharth.Shinde

    This is not something possible, as requested, even with reflection.
    I can't find the reason for having that kind of implementation at runtime.. your compiled assembly is not going to change once it's compiled.
    The way references are listed from within visual studio is probably using metadata gathered from the background compiler. When you write code, the compiler run pre-compilation tests, this is the same feature that will display error in your code before you
    compile, or complete your intelisense for types that aren't even compiled in the assembly.
    So, the only way for you to analyze this kind of thing would be to use something like ILDASM to disasemble your compiled libraries and gather metadata from the resulting MSIL. That would not work if you are using code obfuscation by the way.

  • How to write a application using WDJ with the adobe form ?

    Hi, experts,
    I don't know how to write a application using !!webdynpro for java!! with the adobe form so that I can fill data to the adobe form and get data from the adobe form.
    Note: I have configed the ADS(adobe document services),and I can create a application with a interactiveform in webdynpro for abap and run it successfully, so that I can  fill data to the adobe form and get data from the adobe form.
    Do you give me some hint?
    Thanks a lot.
    Best regards,
    tao
    Edited by: wang tao on Sep 9, 2008 8:59 AM

    Hi,
    Refers the following links.
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/4fd2d690-0201-0010-de83-b4fa0c93e1a9
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/5f27e290-0201-0010-ff82-c21557572da1
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/70c9a954-aa20-2a10-64bb-ea0835204e03
    Thanks
    Abhilasha.

  • How to write a Query a table and the return result is the column name

    Hi All
    Pls advise how to write a query whereas the return result is the
    column name.
    I know there is describe <table_name>;
    Is there any other ways?
    Pls advise
    Tj
    Edited by: user600866 on Oct 14, 2008 12:13 AM

    Data Dictionary table user_tab_columns has all the column names. You can query that and get what ever you want.
    To get the column list of a table just query
    select *
      from user_tab_columns     
    where table_name = <your_table>Edited by: Karthick_Arp on Oct 14, 2008 12:18 AM

  • How do I make a batch file if the .class file uses a foreign package?

    I am trying to make an MS-DOS batch file using the bytecode file from the Java source file, called AddFields.java. This program uses the package BreezySwing; which is not standard with the JDK. I had to download it seperately. I will come back to this batch file later.
    But first, in order to prove the concept, I created a Java file called Soap.java in JCreator. It is a very simple GUI program that uses the javax.swing package; which does come with the JDK. The JDK is currently stored in the following directory: C:\Program Files\Java\jdk1.6.0_07. I have the PATH environment variable set to the 'bin' folder of the JDK. I believe that it is important that this variable stay this way because C:\Program Files\Java\jdk1.6.0_07\bin is where the file 'java.exe' and 'javac.exe' are stored. Here is my batch file so far for Soap:
    @echo off
    cd \acorn
    set path=C:\Program Files\Java\jdk1.6.0_07\bin
    set classpath=.
    java Soap
    pause
    Before I ran this file, I compiled Soap.java in my IDE and then ran it successfully. Then I moved the .class file to the directory C:\acorn. I put NOTHING ELSE in this folder. then I told the computer where to find the file 'java.exe' which I know is needed for execution of the .class file. I put the above text in Notepad and then saved it as Soap.bat onto my desktop. When I double click on it, the command prompt comes up in a little green box for a few seconds, and then the GUI opens and says "It Works!". Now that I know the concept of batch files, I tried creating another one that used the BreezySwing package.
    After I installed my JDK, I installed BreezySwing and TerminalIO which are two foreign packages that make building code much easier. I downloaded the .zip file from Lambert and Osborne called BreezySwingAndTerminalIO.zip. I extracted the files to the 'bin' folder of my JDK. Once I did this, and set the PATH environment variable to the 'bin' folder of my JDK, all BreezySwing and TerminalIO programs that I made worked. Now I wanted to make a batch file from the program AddFields.java. It is a GUI program that imports two packages, the traditional GUI javax.swing package and the foreign package BreezySwing. The user enters two numbers in two DoubleField objects and then selects one of four buttons; one for each arithmetic operation (add, subtract, multiply, or divide). Then the program displays the solution in a third DoubleField object. This program both compiles and runs successfully in JCreator. So, next I moved the .class file from the MyProjects folder that JCreator uses to C:\acorn. I put nothing else in this folder. The file Soap.class was still in there, but I did not think it would matter. Then I created the batch file:
    @echo off
    cd \acorn
    set path=C:\Program Files\Java\jdk1.6.0_07\bin
    set classpath=.
    java AddFields
    pause
    As you can see, it is exactly the same as the one for Soap. I made this file in Notepad and called it AddFields.bat. Upon double clicking on the file, I got this error message from command prompt:
    Exception in thread "main" java.lang.NoClassDefFoundError: BreezySwing/GBFrame
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:12
    4)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
    at java.net.URLClassLoader.access$000(URLClassLoader.java:56)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
    at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
    Caused by: java.lang.ClassNotFoundException: BreezySwing.GBFrame
    at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
    at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
    ... 12 more
    Press any key to continue . . .
    I know that most of this makes no sense; but that it only means that it cannot find the class BreezySwing or GBFrame (which AddFields extends). Notice, however that it does not give an error for javax.swing. If I change the "set path..." command to anything other than the 'bin' folder of my JDK, I get this error:
    'java' is not recognized as an internal or external command,
    operable program or batch file.
    Press any key to continue . . .
    I know this means that the computer cannot find the file 'java.exe' which I believe holds all of the java.x.y.z style packages (native packages); but not BreezySwing or any other foreign packages. Remember, I do not get this error for any of the native Java packages. I decided to compare the java.x.y.z packages with BreezySwing:
    I see that all of the native packages are not actually visible in the JDK's bin folder. I think that they are all stored in one of the .exe files in there because there are no .class files in the JDK's bin folder.
    However, BreezySwing is different, there is no such file called "BreezySwing.exe"; there are just about 20 .class files all with names like "GBFrame.class", and "GBActionListener.class". As a last effort, I moved all of these .class files directly into the bin folder (they were originally in a seperate folder called BreezySwingAndTerminalIO). This did nothing; even with all of the files in the same folder as java.exe.
    So my question is: What do I need to do to get the BreezySwing package recognized on my computer? Is there possibly a download for a file called "BreezySwing.exe" somewhere that would be similar to "java.exe" and contain all of the BreezySwing packages?

    There is a lot of detail in your posts. I won't properly quote everything you put (too laborious). Instead I'll just put your words inside quotes (").
    "..there are some things about the interface that I do not like."
    Like +what?+ This is not a help desk, and I would appreciate you participating in this discussion by providing details of what it is about the 'interface' of webstart that you 'do not like'. They are probably misunderstandings on your part.
    "Some of the .jar files I made were so dangerously corrupt, that I had to restart my computer before I could delete them."
    Corrupt?! I have never once had the Java tools produce a corrupt Jar. OTOH, the 'cannot delete' problem might relate to the JRE gaining a file lock on the archive at run-time. If the file lock persisted after ending the app., it suggests that the JRE was not properly shut down. This is a bug in the code and should be fixed. Deploying as .class files will only 'hide' the problem (from casual inspection - though the Task Manager should show the orphaned 'java' process).
    "I then turned to batch files for their simple structure and portability (I managed to successfully transport a java.util containing batch file from my computer to another). This was what I did:
    - I created a folder called Task
    - Then I copied three things into this folder: 1. The file "java.exe" from my JDK. 2. The program's .class file (Count.class). and 3. The original batch file.
    - Then I moved the folder from a removable disk to the second computer's C drive (C:\Task).
    - Last, I changed the code in the batch file...:"
    That is the +funniest+ thing I've heard on the forums in the last 72 hours. You say that is easy?! Some points.
    - editing batch files is not scalable to 100+ machines, let alone 10000+.
    - The fact that Java worked on the target machine was because it was +already installed.+ Dragging the 'java.exe' onto a Windows PC which has no Java will not magically make it 'Java enabled'.
    And speaking of Java on the client machine. Webstart has in-built mechanisms to ensure that the end user has the minimum required Java version to run the app. - we can also use the [deployJava.js|http://java.sun.com/javase/6/docs/technotes/guides/jweb/deployment_advice.html#deplToolkit] on the original web page, to check for minimum Java before it puts the link to download/install the app. - if the user does not have the required Java, the script should guide them through installing it.
    Those nice features in deployJava.js are available to applets and apps. launched using webstart, but they are not available for (plain) Jar's or loose class files. So if 'ensuring the user has Java' is one of the requirements for your launch, you are barking up the wrong tree by deploying loose class files.
    Note also that if you abandon webstart, but have your app. set up to work from a Jar, the installation process would be similar to above (though it would not need a .bat file, or editing it). This basic strategy is one way that I provide [Appleteer (as a downloadable ZIP archive)|http://pscode.org/appleteer/#download]. Though I side-step your part 1 by putting the stuff into a Jar with the path Appleteer/ - when the user expands the ZIP, the parts of the app. are already in the Appleteer directory.
    Appleteer is also provided as a webstart launched application (and as an applet). Either of those are 'easier' to use than the downloadable ZIP, but I thought I would provide it in case the end user wants to save it to disk and transport the app. to a machine with no internet connection, but with Java (why they would be testing applets on a PC with no internet connection, I am not sure - but the option is there).
    "I know that .jar and .exe files are out because I always get errors and I do not like their interfaces. "
    What on earth are you talking about? Once the app. is on-screen, the end user would not be able to distinguish between
    1) A Jar launched using a manifest.
    2) A Jar launched using webstart.
    3) Loose class files.
    Your fixation on .bat files sounds much like the adage that 'If the only tool you have is a hammer, every job starts to look like a nail'.
    Get over them, will you? +Using .bat files is not a practical way to provide a Java app. to the end user+ (and launching an app. from a .bat looks quite crappy and 'second hand' to +this+ user).
    Edit 1:
    The instructions for running Appleteer as a Jar are further up the page, in the [Running Appleteer: Application|http://pscode.org/appleteer/#application] section.
    Edited by: AndrewThompson64 on May 19, 2009 12:06 PM

  • What is the impact of creating a thread in a class or outside of the class

    Hi Java Experts;
    I have 2 code examples on how to create new threads.
    The first example instantiates, Starts and Joins the Threads Externally.
    The second example Starts and Joins the New Thread Internally.
    QUESTIONS:
    1. Is it true that creating the thread internally creates 2 new threads instead of just one. Because the instance of Class A is a thread. And when it starts itself that's another thread.
    2. Am I correct when I say that the another difference between the two is that in the external one, Class B has to wait before creating new instances since the join method is in its loop. But the advantage of Internally created is that Class B can create can create 100 new threads without having to wait on the join.
    are these correct - and is there any other implication of using one versus another.
    Scenario 1: Start and Join the New Thread Externally
    class A implements Runnable{
      public void run(){
      public A(){}
    public String getMiscProperties(){
       //This Methods must be called Only After this thread returns from the run method
    // this is the calling class
    class B implements Runnable{
      public void run(){
         while(true){
         A p2 = new A();
         Thread t2 = new Thread(p2);
         t2.setDaemon(true);
         t2.start();
         try{
              t2.join();
         }catch(InterruptedException ie){  }
            System.out.println(p2.getMiscProperties());
      public B(){}
    }Scenario 2: Start and Join the New Thread Internally
    class A implements Runnable{
      public void run(){
      public A(){
         Thread t2 = new Thread(this);
         t2.setDaemon(true);
         t2.start();
         try{
              t2.join();
         }catch(InterruptedException ie){  }
      public String getMiscProperties(){
       //This Methods must be called Only After this thread returns from the run method
    // this is the calling class
    class B implements Runnable{
      public void run(){
         while(true){
         A p2 = new A();
            System.out.println(p2.getMiscProperties());
      public B(){}

    Hi,
    1. A thread is created only after you do a
    new Thread(..); // (or its subclass)It does not matter whether you do that internally or externally. You do not get a new thread from constructing a class that implements Runnable if this class is not a Thread (or its subclass).
    In particular, the line:
    A p2 = new A();does not create a new thread by itself. You can verify this by putting
    System.out.println(Thread.currentThread().getName());before that line and in the class 'A' constructor.
    2. No. Your internally created thread will complete first because it is joined before B.run() gets a chance to create another thread.
    If you want to start new threads before other threads complete, you have to do so before the join() method, or you can eliminate join() completely. When you call T.join(), that thread waits for thread T to complete before carrying on.

  • FM/BAPI for assigning a class and value for the class instead of manually d

    Hi guys,
    Instead of manually adding equipment class and assigning value for the class added can i get a FM or BAPI.
    this is for transaction IE02.
    rewards will be given.

    Hi
    I hope this thread can help you
    Characteristic Value
    Re: Equipment Characteristic Value
    Change Equipment Using Transaction IE02
    Regards
    pavan

  • Accessing data in a class when not in the class library

    Spoiler (Highlight to read)
    Hi,
    I'm fairly new to labview classes and am wondering if it is possible to make public or read the value coming from a lvclass control.
    If I highlight the control all the values are listed as private and I can't unbundle the class, of course once I make a vi a member of the lvclass I can unbundle the class.  However there are two elements that I want o be globally available, is this possible?
    Sean

    You need to select your class, not the ctl.
    This is the same thing as making a member vi for the class, it's just a shortcut for making a .vi that can output the private date.
    ( The way LabVIEW has implemented the OOP, all class attributes are private. And there are no way to make them public or protected. The only way to access the data from outside is by making a Accessor. )
    Here are some reading: http://zone.ni.com/devzone/cda/tut/p/id/3574

  • How to write a JAVA program to execute the SQL queries

    I have a database in the Microsoft Access queries and I need to execute the query by some how write the Java program to make it execute the query. because I need to get the different of time so I know how fast each query run.
    Thank you

    You need jdbc-driver for MSAccess for run this example:
    JDBCClient.java
    import java.util.Properties;
    import java.lang.String;
    import java.sql.DriverManager;
    import java.sql.Connection;
    import java.sql.PreparedStatement;
    import java.sql.ResultSet;
    import java.sql.ResultSetMetaData;
    import java.io.FileInputStream;
    import java.io.FileOutputStream;
    import java.io.BufferedOutputStream;
    import java.lang.System;
    import java.lang.Class;
    import java.sql.SQLException;
    import java.util.Date;
    import java.util.Locale;
    import java.text.DateFormat;
    import java.sql.Time;
    public class JDBCClient{
        private String DriverName = new String();
        private String DatabaseURL = new String();
        private String UserName = new String();
        private String Password = new String();
        private String SQLFile = new String();
        private String OutputFile = new String();
        private String Separator = new String();
        private boolean NeedColumnHeaders;
        private String EncodingParamName = new String();
        private String EncodingValue = new String();
        private String OutputEncoding = new String();
        private boolean AfterLastColumnSeparator;
        JDBCClient( String propfilename){
         System.out.println( "Initializing...");
         Properties properties = new Properties();
         try{
             properties.load( new FileInputStream( propfilename));
         catch( Exception e){
                 System.out.println( "Error: " + e.toString());
             System.exit( 0);
         DriverName = properties.getProperty( "DriverName");
         DatabaseURL = properties.getProperty( "DatabaseURL");
         UserName = properties.getProperty( "UserName");
         Password = properties.getProperty( "Password");
         SQLFile = properties.getProperty( "SQLFile");
         OutputFile = properties.getProperty( "OutputFile");
         Separator = properties.getProperty( "Separator");
         if( properties.getProperty( "NeedColumnHeaders").compareToIgnoreCase( "yes") == 0 ||
             properties.getProperty( "NeedColumnHeaders").compareToIgnoreCase( "true") == 0)
             NeedColumnHeaders = true;
         else
         if( properties.getProperty( "NeedColumnHeaders").compareToIgnoreCase( "no") == 0 ||
             properties.getProperty( "NeedColumnHeaders").compareToIgnoreCase( "false") == 0)
             NeedColumnHeaders = false;
         else{
                 System.out.println( "Invalid value for \"NeedColumnHeaders\" property (logical expected)");
             System.exit( 0);
         EncodingParamName = properties.getProperty( "EncodingParamName");
         EncodingValue = properties.getProperty( "EncodingValue");
         OutputEncoding = properties.getProperty( "OutputEncoding");
         if( properties.getProperty( "AfterLastColumnSeparator").compareToIgnoreCase( "yes") == 0 ||
             properties.getProperty( "AfterLastColumnSeparator").compareToIgnoreCase( "true") == 0)
             AfterLastColumnSeparator = true;
         else
         if( properties.getProperty( "AfterLastColumnSeparator").compareToIgnoreCase( "no") == 0 ||
             properties.getProperty( "AfterLastColumnSeparator").compareToIgnoreCase( "false") == 0)
             AfterLastColumnSeparator = false;
         else{
                 System.out.println( "Invalid value for \"AfterLastColumnSeparator\" property (logical expected)");
             System.exit( 0);
         try{
             byte[] EOL = new byte[2];
             EOL[0] = 13;
             EOL[1] = 10;
             Class.forName( DriverName);
             Properties connInfo = new Properties();
             connInfo.put( "user", UserName);
             connInfo.put( "password", Password);
             if( EncodingParamName.length() != 0 && EncodingValue.length() != 0)
              connInfo.put( EncodingParamName, EncodingValue);
                 Connection connection = DriverManager.getConnection( DatabaseURL, connInfo);
             FileInputStream in = new FileInputStream( SQLFile);
             byte[] buffer = new byte[in.available()];
             in.read( buffer);
             in.close();
             String SQL = new String( buffer);
                 PreparedStatement statement = connection.prepareStatement( SQL);
             Date d1 = new Date();
                 System.out.println( "Database connected at " + d1 + " Executing statement...");
                ResultSet resultSet = null;
             if( statement.execute())
              resultSet = statement.getResultSet();
             else{
                  System.out.println( "Script updates " + statement.getUpdateCount() + " records.");
              System.exit( 0);
                 ResultSetMetaData metaData = resultSet.getMetaData();
                 BufferedOutputStream out = new BufferedOutputStream( new FileOutputStream( OutputFile));
             if( NeedColumnHeaders && metaData.getColumnCount() > 0){
              String head = new String();
              for( int i = 1; i < metaData.getColumnCount(); i++)
                  head += metaData.getColumnName( i) + Separator;
              head += metaData.getColumnName( metaData.getColumnCount());
              out.write( head.getBytes( OutputEncoding), 0, head.length());
              out.write( EOL, 0, 2);
             String record = new String();
             while( resultSet.next()){
              record = "";
              for( int i = 1; i < metaData.getColumnCount(); i++)
                  record += resultSet.getString( i) + Separator;
              record += resultSet.getString( metaData.getColumnCount());
              if( AfterLastColumnSeparator)
                  record += Separator;
              out.write( record.getBytes( OutputEncoding), 0, record.length());
              out.write( EOL, 0, 2);
             out.close();
             Date d2 = new Date();
                 System.out.println( "Done at " + d2);
                 System.out.println( "Executing time " + new Time( d2.getTime() - d1.getTime() - 10800000));
         catch( ClassNotFoundException e){
                 System.out.println( e.toString());
         catch( SQLException e){
                 System.out.println( e.toString());
         catch( java.io.IOException e){
                 System.out.println( e.toString());
         System.exit( 0);
        public static void main( String args[]){
         if( args.length == 1)
             new JDBCClient( args[0]);
         else
             System.out.println( "Usage JDBCClient <properties_file>");
    }JDBCClient.properties ( for Oracle database)
    DriverName=oracle.jdbc.driver.OracleDriver
    DatabaseURL=jdbc:oracle:thin:@192.168.1.1:1521:test
    UserName=test
    Password=test
    SQLFile=test.sql
    OutputFile=test.csv
    Separator=*
    NeedColumnHeaders=yes
    EncodingParamName=
    EncodingValue=
    OutputEncoding=windows-1251
    AfterLastColumnSeparator=yestest.sql
    select * from users;

Maybe you are looking for