Showing posts with label database-connection. Show all posts
Showing posts with label database-connection. Show all posts

Wednesday, January 31, 2018

How to reuse ArrayDescriptor?

Leave a Comment

I tried the code below:

public class Abc {      private ArrayDescriptor arrayDesc;      void init() {        connection = //create connection         arrayDesc = ArrayDescriptor.createDescriptor("DBTYPE",connection);     }      void m1() {         conn1 = //create connection         ARRAY array_to_pass1 = new ARRAY( arrayDesc , conn1, idsArray1 );      }      void m2() {         conn2 = //create connection         ARRAY array_to_pass2 = new ARRAY( arrayDesc , conn2, idsArray2 );      }  } 

This code is giving the error below:

table.java.sql.SQLException: Missing descriptor at oracle.sql.DatumWithConnection.assertNotNull(DatumWithConnection.java:103)

How can this be resolved?

2 Answers

Answers 1

ArrayDescriptor is deprecated. Assuming your connection objects are of type OracleConnection, try using createOracleArray instead - something like this:

public class Abc {     void init() {         connection = //create connection     }      void m1() {         conn1 = //create connection         array array_to_pass1 = conn1.createOracleArray(arrayDesc, idsArray1);      }      void m2() {         conn2 = //create connection         array array_to_pass2 = conn2.createOracleArray(arrayDesc, idsArray2);      } } 

Note: Using this method, the arrays will be of type java.sql.Array rather than oracle.sql.ARRAY.

Answers 2

new ARRAY must be called with an ArrayDescriptor that uses the same connection. So what you're trying to do won't work. Note that each connection has a cache of descriptors so creating the descriptor will happen just once per connection.

Read More

Wednesday, July 19, 2017

VBA: Runtime Error '70' when accessing a database

Leave a Comment

I have an .xlsm-file. It contains a list of movies, and is supposed to search the online database omdbapi.com for information on each movie, and insert this information, starting in column F.

A MWE looks as follows.

In the first sheet, it says just Lawless (2012) in cell A1, the name of the first movie. Columns 4 and 5 contain the name with spaces turned to + and the year extracted from the first cell, respectively, but I skip that code here. In the example, it looks like this:

enter image description here

The VBA macro is as follows:

Sub test()  mystr = "http://www.omdbapi.com/?t=" & Cells(1, 4).Value & "&y=" & Cells(1, 5).Value & "&r=xml"         ActiveWorkbook.XmlImport URL:=mystr, ImportMap:=Nothing, Overwrite:=True, Destination:=Cells(1, 6)             ActiveWorkbook.Connections.Item(1).Delete  End Sub 

This has code has worked for the longest time. Now, I encounter the error:

Run-time error '70':

Permission denied.

I searched what that means, but did not find anything that seemed applicable. Furthermore, the internet connection is working and not clogged up by other connections, and excel has all rights to access the web.

1 Answers

Answers 1

please try this ... the result may answer your question about the code 70

Sub test()      mystr = "http://www.omdbapi.com/?t=" & Cells(1, 4).Value & "&y=" & Cells(1, 5).Value & "&r=xml"      Debug.Print mystr       ' copy the url from the "Immediate window"                             ' and paste into a web browser address bar,                             ' then navigate to that webpage                             ' (view immediate window by pressing ctrl-G)  End Sub 
Read More

Saturday, May 7, 2016

Open paradox / borland database as single file

Leave a Comment

my question is: how to connect java tp paradox / borland database ".DB" single files?

Here's what I have: screenshot So, it's Paradox 7 database files.

I'm trying drivers: http://www.hxtt.com/paradox.html & https://code.google.com/archive/p/paradoxdriver/ as:

String url = "jdbc:paradox:/D:/BABAK/powerGold/SongTitle.DB"; Connection con = DriverManager.getConnection(url); 

But both throws exceptions like:

D:/BABAK/powerGold/SongTitle.DB isn't a database directory path! 

As you can see, it is trying to find some database folder, but I have only single files! Also, "jdbc:paradox:/D:/BABAK/powerGold" (path to all .DB files folder) didn't work as well.

So, anybody, please help me to figure out, how to open this type of DB in my Java app.

1 Answers

Answers 1

you're not trying to open the database doing so but a specific file of the whole DB. In fact your DB is composed of files .db, .px ....

The best approach to do so, is to migrate since this DB is not supported, and realy brings a lot of bugs.

I will recommand you to use migrate your database.

  1. install Paradox Database Reader or Editor
  2. export tables to CSV files
  3. import tables in mysql Database (for example)

If you still want to connect this DB without migration with java, share in private a file .db and will give a try now.

Read More