Problem in metadata.getColumns...pl help me

Hello
This is my program
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection conn = DriverManager.getConnection(url+dataSource,Uname,Pwd);
out = new FileOutputStream("myfile.sql");
p = new PrintStream(out);
DatabaseMetaData metadata = conn.getMetaData();
ResultSet rsTables = metadata.getTables("",Uname,"%",tabtypes);
p.println("/* File Created on");
while(rsTables.next())
String tmp = rsTables.getString("TABLE_NAME");
// String coltype = rs1.getType(2);
p.println("Create Table "+ tmp + "(");
//when i use this
ResultSet rsColumns = metadata.getColumns("",Uname,tmp,"");
it says the foll. error
ava.sql.SQLException: [Oracle][ODBC]Driver not capable.
     at sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:6031)
     at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:6188)
     at sun.jdbc.odbc.JdbcOdbc.SQLColumns(JdbcOdbc.java:2174)
     at sun.jdbc.odbc.JdbcOdbcDatabaseMetaData.getColumns(JdbcOdbcDatabaseMetaData.java:2576)
     at mypackage.Dbcopy.doCopy(Dbcopy.java:72)
     at mypackage.myclass.main(myclass.java:20)
but the foll. line works fine...
ResultSet rsTables = metadata.getTables("",Uname,"%",tabtypes);
Let me know if that one is driver specific....any other way i can use it.
I m trying to query the tables in a oracle database and output a .sql file which has
create table <tablename>(colname, datatype)
and when i run this .sql file it should create thos tables.
Thanks
SS

Hello,
This is my program.
I am able to get the tables and their columnnames , now my problem is i need to get the actual datatypes and their length.
As of now i need to get the datatype from oracle and its length. one more problem is i m checking for the last column if its the last column in table i need to close with this brace ")" else i need to put a comma and continue. when i m using the isafterlast method its not working. how to check that.
It should be of great help to me if you could let me know....as i need to give it to my manager on monday morning.
Thanks & Regards
Srinivas
public class Dbcopy2 {
public static String Uname;
public static String Pwd;
public static String url = "";
public static String cat;
public static FileOutputStream out;
public static PrintStream p;
public static String dattype;
public static String tabtypes[]={"TABLE"};
public Dbcopy2(String url,String Uname, String Pwd) {
this.url = url;
this.Uname = Uname;
this.Pwd = Pwd;
public void doCopy(String datasource)
try {
DriverManager.registerDriver (new oracle.jdbc.driver.OracleDriver());
Connection conn = DriverManager.getConnection(url, Uname, Pwd);
out = new FileOutputStream("myfile.sql");
p = new PrintStream(out);
GregorianCalendar dt = new GregorianCalendar();
     p.println("--Rem File Created on " + dt.getTime().toString());
DatabaseMetaData metadata = conn.getMetaData();
ResultSet rsTables = metadata.getTables(null,null,"%",tabtypes);
ResultSetMetaData md = rsTables.getMetaData();
          int cols=md.getColumnCount();
while(rsTables.next())
          if (rsTables.getString(2).equalsIgnoreCase(Uname))
               String schemaname = rsTables.getString(2);
               String tbname = rsTables.getString(3);
               p.println("Create table " + tbname + "(");
     ResultSet rsColumns = metadata.getColumns(null,schemaname,tbname,null);
               ResultSetMetaData md2 = rsColumns.getMetaData();
String colname=null;
String coltype=null;
String colsize=null;
String colltype=null;
     while(rsColumns.next())
          colname = rsColumns.getString(4);
          coltype = rsColumns.getString(5);
          colsize = rsColumns.getString(7);
          p.print(colname + " ");
     /* if (coltype = (java.sql.Types.CHAR)) // i m getting some error here and is this the right way to do it//
     colltype = "CHAR" ;
if(rsColumns.isAfterLast())
                                             p.print(coltype+" ("+colsize+")");
     else
     p.print(coltype+" ("+colsize+"),");
     }p.println(");");
p.println();
} catch(Exception e)
e.printStackTrace() ;
public static void main(String[] args) {
Dbcopy2 db = new Dbcopy2("jdbc:oracle:thin:@192.168.0.21:1521:orcl","scott","tiger");
//Dbcopy2 db = new Dbcopy2("jdbc:oracle:thin:","scott","tiger");
db.doCopy("isol");

Similar Messages

  • My daughter has spitefully changed my password and has refused to tell me. I have so much medical information that I can not lose. Is there anyway to get around this problem. Please I need Help fast.

    My daughter has spitefully changed my password and has refused to tell me. I have so much medical information that I can not lose. Is there anyway to get around this problem. Please I need Help fast.

    Connect the iPod to your syncing computer and restore it via iTunes.  However, if iTunes asks for the unknown passcode you need to place the iPod in recovery mode and then restore the iPod from backup.  For recovey mode see:
    iPhone and iPod touch: Unable to update or restore
    "If you cannot remember the passcode, you will need to restore your device using the computer with which you last synced it. This allows you to reset your passcode and resync the data from the device (or restore from a backup). If you restore on a different computer that was never synced with the device, you will be able to unlock the device for use and remove the passcode, but your data will not be present. Refer to Updating and restoring iPhone and iPod touch software."
    Above is from:
    http://support.apple.com/kb/ht1212

  • My IPod no longer shuffles songs within playlists that are clearly set to shuffle.  It is about 3/4 full so I thought of maybe compressing the files to get more space.  Do you think that is the problem and if that might help?

    My IPod no longer shuffles songs within playlists that are clearly set to shuffle.  It is about 3/4 full so I thought of maybe compressing the files to get more space.  Do you think that is the problem and if that might help?

    Storage space on the iPod would not affect shuffled playlists or playlist shuffling, though substantially full iPods may wind up skipping songs on larger playlists after a while, and require a restart.  As for compressing the files themselves, you can automatically re-encode files to a lower bitrate by checking the box on the summary page when your iPod is connected to your PC/Mac.
    As for the shuffle problem, after restarting your iPod (hold the center button and Menu for a few seconds, until the Apple logo appears), make sure you're telling the iPod to shuffle the songs in a playlist by repeatedly clicking the center button until the Suffle Menu comes up, then scroll to the right to turn it on.  From that song forward, the playlists' contents should be shuffled every time the playlist ends, or is accessed from a new song.
    Shuffle does sometimes turn itself off, I've found, so double-check the setting is still on.  Also, iPods shuffle by randomly assigning a playlist order for your songs, which is different from traditional shuffle (on, say, iTunes or Windows Media Player, where the new song is determined at random upon the current track ending.  The iPod only chooses a random order of songs when you shuffle, to conserve battery life and queue up songs coming up on the playlist in the event of a shock).

  • I connected my ipod touch 4g wi-fi with laptop ad hoc network....it's showing wi-fi signals but internet is not working...what is the problem in that can anyone help me...inadvances thanks

    I connected my ipod touch 4g wi-fi with laptop ad hoc network....it's showing wi-fi signals but internet is not working...what is the problem in that can anyone help me...inadvances thanks

    my laptop is Windows 7 and ip is this
    192.168.102.12
    255.255.255.0
    192.168.102.1
    DNS
    192.168.254.2
    192.168.254.3
    in ipod touch 4g is DHCP and its showing
    ip address 169.254.192.139
    subnet mask 255.255.0.0.
    remaining all blank

  • [svn] 4143: Fixed problem with metadata in SelectionFormatTextStyles. as so that named colors work for selectionColor, unfocusedSelectionColor, and inactiveSelectionColor attributes on Gumbo components.

    Revision: 4143
    Author: [email protected]
    Date: 2008-11-19 14:53:40 -0800 (Wed, 19 Nov 2008)
    Log Message:
    Fixed problem with metadata in SelectionFormatTextStyles.as so that named colors work for selectionColor, unfocusedSelectionColor, and inactiveSelectionColor attributes on Gumbo components.
    Thanks, Glenn!
    QE Notes: None
    Doc Notes: None
    Bugs: SDK-18070
    Reviewer: Glenn
    Ticket Links:
    http://bugs.adobe.com/jira/browse/SDK-18070
    Modified Paths:
    flex/sdk/trunk/frameworks/projects/flex4/src/mx/styles/metadata/SelectionFormatTextStyles .as
    flex/sdk/trunk/frameworks/projects/wireframe/bundles.properties

    Revision: 4143
    Author: [email protected]
    Date: 2008-11-19 14:53:40 -0800 (Wed, 19 Nov 2008)
    Log Message:
    Fixed problem with metadata in SelectionFormatTextStyles.as so that named colors work for selectionColor, unfocusedSelectionColor, and inactiveSelectionColor attributes on Gumbo components.
    Thanks, Glenn!
    QE Notes: None
    Doc Notes: None
    Bugs: SDK-18070
    Reviewer: Glenn
    Ticket Links:
    http://bugs.adobe.com/jira/browse/SDK-18070
    Modified Paths:
    flex/sdk/trunk/frameworks/projects/flex4/src/mx/styles/metadata/SelectionFormatTextStyles .as
    flex/sdk/trunk/frameworks/projects/wireframe/bundles.properties

  • TS1538 I have tried everything but I can't connect my iphone to my laptop. It says that apple mobile device failed to be installed. I have read everything on the internet and did everything but still am facing the same problem. Can you please help me.

    I have tried everything but I can't connect my iphone to my laptop. It says that apple mobile device failed to be installed. I have read everything on the internet and did everything but still am facing the same problem. Can you please help me.

    Again without stating the trouble shooting steps you have taken, its hard to direct you with any information.
    Try a different port on the computer.
    Does the iphone beep when u plug it up. ?
    Plug iphone into computer and give it 3 to 4 minutes to see if it connects and is running slow.,
    Delete the apple mobile device from your computer.
    Upgrade itunes to newest version.
    Is you USB cord defective ?
    Any USB 3.0 on your system ? .
    Delete or Disable  any antivirus program on your computer ?
    I will tell u the problem is your computer not the phone.
    We could do this for hours.

  • My comp with Windows7 doesn´t recognise iPhone 5c. I reinstalled USB drivers,iTunes,restarted both devices but without positive result. iPad is recognised on the same comp without problems. Could me somebody help?

    My comp with Windows7 doesn´t recognise iPhone 5c. I reinstalled USB drivers,iTunes,restarted both devices but without positive result. iPad is recognised on the same comp without problems. Could me somebody help?

    Hi there tsubert,
    You may find the troubleshooting steps in the article below helpful.
    iOS: Device not recognized in iTunes for Windows
    http://support.apple.com/kb/ts1538
    -Griff W. 

  • Having problem buying online.need your help since it's my first time here.apple is asking for my billing address but when i enter my address here in qatar,it's saying i should enter a valid zip code within the u.s.does it mean i can't buy online

    having problem buying online.need your help since it's my first time here.apple is asking for my billing address but when i enter my address here in qatar,it's saying i should enter a valid zip code within the u.s.does it mean i can't buy online even if it wil be shipped within u.s. only?

    To buy in for delivery in Qatar, you should be starting from the Apple Qatar site:
    http://www.apple.com/qa/
    Do you have an Apple-ID? if you do, then you should not have to enter your Address again, and may be able to sidestep the US Zip Code issue.

  • Hi fellow apple guys, i have this problem. Hope you can help me. I don't know how to use the function keys (F1 to F12) on my macbook air. Pls help

    Hi fellow apple guys, i have this problem. Hope you can help me. I don't know how to use the function keys (F1 to F12) on my macbook air. Pls help

    Out of the box, to use the function keys as function keys, hold down the fn key when you press the key. Otherwise, you get the picture function on the key. You can reverse this behavior in the Keyboard system prefs.

  • I am trying to download library books onto my Nook reader and keep receiving the message that the book isn't authorized to download.  Have not downloaded a book in several months but haven't had this problem in the past.  Help?

    I am trying to download library books onto my Nook reader and keep receiving the message that the book isn't authorized to download.  Have not downloaded a book in several months but haven't had this problem in the past.  Help?

    same problem for me. I am using abe edition 3 as I don't think 4 can be used with kobo. Book has been downloaded to kobo but it can't be read as it is not authorised.Help please

  • Does Apple read these posts? I'm having the same trouble connecting iphone4s to my  2012 Prius V. Apple said it was a Toyota problem. Apple needs to help us all!!!!!!!

    Cannot connect new iPhone 4S to my Prius V bluetooth . Have been trying so many different fixes. Maybe if the almighty Apple read the posts, the problem could be fixed. Help!!!

    From http://www.toyota.com/entune/what-is-entune/phones.html we read:
    "Android™ and Blackberry® wirelessly connect your phone to the available Entune™-equipped Toyota using Bluetooth®. The iPhone® is connected via a USB data cable."
    There's clearly something different about the iPhone's bluetooth capabilities than the other two phones.  To say it's only Apple's or Toyota's problem isn't very helpful for anyone because, yes, Toyota should have designed Entune for full compatibility with iOS devices and, yes, Apple should have designed the iPhone to be at least as capable as the other phones wrt bluetooth.
    I still don't know who to holler at.

  • HT201363 Hello I forgot my Security question of my Apple ID ? I don't kow what should I do and how to solve this problem ? could you please help  ?

    Hello I forgot my Security question of my Apple ID ? I don't kow what should I do and how to solve this problem ? could you please help  ?

    You need to ask Apple to reset your security questions; ways of contacting them include phoning AppleCare and asking for the Account Security team, clicking here and picking a method for your country, and filling out and submitting this form.
    They wouldn't be security questions if they could be bypassed without Apple verifying your identity.
    (104569)

  • Developer 6 Timer Problem... Please help

    Hi all,
    I have installed Developer 6(Oracle Product) on my system. I am facing a strange problem whenever I try to use Create_Timer built in. The cursor moves to starting of the Item being modified as soon as the space bar is pressed (timed for timer expiration). If I remove the Built-in the problem is resolved.
    Please help urgently.
    Regards
    Anand

    Upgrade to the latest patch and the problem shoudl go away - this issue was fixed I think in 6.0.8.13+
    You can also try setting Keey Cursor position to Yes on the item.

  • LR4 Problem Saving Metadata

    Ever since I upgraded to LR4 I have noticed a problem with metadata. I have created a Smart Collection  with the rule "Metadata status is Has Been Changed" to show me all of the images that I have updated metadata but not written the changes to disk. I am seeing the number of images in this collection gradually increase ... but not because I am working on images!
    If I go to the collection, do a "Select All" and then do a "Save Metadata to Files", sure enough the disk goes crazy and the images are removed from the collection. BUT ... if I just sit back and watch ... after a few seconds of inactivity the smart collection gradually fills up again ... with the same Images I just saved!!!
    Like I mentioned, it seems like this list is getting gradually longer and longer. A few months ago I had about 20 images that were behaving like this, but now I have over 250!
    Anyone seeing the same thing? Or have any suggestions as to the cause?
    I'm running LR4.1 on an iMac running Mac OS X Lion (10.7.4).

    Lr4.3/Win7 pro 64bit-file format dng without write to xmp automatically
    This returning group of 'metadata changed' issue has repeated itself in past version and currently.
    I select the returnees and use the menu command  'Update dng preview and save metadata'  That appears to do the trick for no reappearance occurs.
    Since I'm 'catching up' on past images that were not processed I assumed this issue could be connected to 'building the previews'.
    Its an annoyance if there are many images that had a metadata change resulting from a simple thing such as keyword edit or move. I learned to do 'save metadata' often rather than watch most of a large group return into view.
    Just repeating the save didn't always work but the 'update previews and save' does complete the action.
    Rose

  • HT1926 i've tried so many times but the problem still exists! please help!!

    i've tried so many times but the problem still exists! please help!!

    Could you describe what your problem is, please?

Maybe you are looking for

  • How to configure Gennic for router?

    I have installed UCCE 9.0. How do I install and configure gennic NIC for the router? The gennic.exe process shows state start pending and waiting. When I go in config manager - > nic explorer and try to add nic I dont see the gennic type there. I onl

  • Configuring Cost Code along with Payroll elements in Timekeeper time entry

    Hi, I am trying to configure cost code as a separate entry along with payroll elements in timekeeper time entry screen. Can any one help me in completing the task. Regards BK

  • Confusion - comparable and comparator

    can any body tell me, why should i use comprator instead of comparable in TreeSort. When i used comparable with compareTo function it shows same result what comparator with compare function shows .. plz help me..

  • New computer needs new install.  [edited by host]

    Adobe STAFF person:  Please Help!  I purchased Adobe Suite from Adobe and threw away old computer.  Now new computer needs new install.  I don't have the CD's.  2 entire days wasted and still no response from CHAT!!!!!!! HORRIBLE!  I don't like Forum

  • SAP books: FICO configuration package

    Hi, Maybe someone of you have this FICO configuration package => http://www.erpgenie.com/publications/fico.htm If yes, please provide short comments, is it helpful? Or maybe you heard any rumors about it?