<p>The .Select() function got several options and this one e.g. can be read as a SQL </p> <pre><code>SELECT * FROM sourceTable WHERE searchColumn = value; </code></pre> Error: gdal-config not found while installing R dependent packages whereas gdal is installed

Then you can import the rows you want as described above.

targetTable.ImportRows(rows[n])

Please point out the point that I am missing:

...for any valid n you like, but the columns need to be the same in each table.

Some things you should know about ImportRow is that there will be errors during runtime when using primary keys!

openSUSE 11.3


xx@linux-y3pi:~/Desktop/R> sudo R CMD INSTALL rgdal_0.7-12.tar.gz
root's password:
* installing to library ‘/usr/lib64/R/library’
* installing *source* package ‘rgdal’ ...
** package ‘rgdal’ successfully unpacked and MD5 sums checked
configure: gdal-config: gdal-config
checking gdal-config usability... ./configure: line 1353: gdal-config: command not found
no
Error: gdal-config not found
The gdal-config script distributed with GDAL could not be found.
If you have not installed the GDAL libraries, you can
download the source from  http://www.gdal.org/
If you have installed the GDAL libraries, then make sure that
gdal-config is in your path. Try typing gdal-config at a
shell prompt and see if it runs. If not, use:
--configure-args='--with-gdal-config=/usr/local/bin/gdal-config'
with appropriate values for your installation.


ERROR: configuration failed for package ‘rgdal’
* removing ‘/usr/lib64/R/library/rgdal’

xx@linux-y3pi:~/Desktop/R> whereis gdal-config
gdal-config: /usr/local/bin/gdal-config


xx@linux-y3pi:~/Desktop/R> gdal-config
Usage: gdal-config [OPTIONS]
Options:
[--prefix[=DIR]]
[--libs]
[--dep-libs]
[--cflags]
[--datadir]
[--version]
[--ogr-enabled]
[--formats]
xx@linux-y3pi:~/Desktop/R>

> sessionInfo()
R version 2.15.1 (2012-06-22)
Platform: x86_64-unknown-linux-gnu (64-bit)


locale:
[1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C
[3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8
[5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8
[7] LC_PAPER=C                 LC_NAME=C
[9] LC_ADDRESS=C               LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C


attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base
>

xx@linux-y3pi:~/Desktop/R> gdal-config --version
1.9.0


xx@linux-y3pi:~/Desktop/R> proj
Rel. 4.8.0, 6 March 2012
usage: proj [ -beEfiIlormsStTvVwW [args] ] [ +opts[=arg] ] [ files ]

linux-y3pi:~ # $PATH
bash: /home/xx/qtsdk-2010.05/qt/bin/:/home/xx/qtsdk-2010.05/bin:/home/xx/qtsdk-2010.05/qt/bin:/home/xx/qtsdk-2010.05/qt/bin/:/home/xx/qtsdk-2010.05/bin:/usr/lib64/mpi/gcc/openmpi/bin:/home/xx/bin:/usr/local/bin:/usr/bin:/sbin:/usr/sbin:/bin:/usr/bin/X11:/usr/X11R6/bin:/usr/games: No such file or directory
113631 次浏览
>= 4.4.9) from http://trac.osgeo.org/proj/;

You can create an Extension for the class "DataTable" to create clones and add them to the table easy:

d(row);

Example usage

DataTable dataTable; // given and contains rows


DataRow row = dataTable.Rows[0]; // Choose one row


// Only create the clone
DataRow clonedRow = dataTable.Clone(row);


// Create the clone and add it to the table
DataRow clonedRowAdded = dataTable.CloneAndAdd(row);

Extension handling this as follows

namespace CustomExtensions
{
public static class DataTableExtensions
{
/// <summary>
/// Operation: Clone sourceRow and add to destinationDataTable
/// </summary>
static public DataRow CloneAndAdd(this DataTable destinationDataTable,
DataRow sourceRow)
{
DataRow clonedRow = destinationDataTable.Clone(sourceRow);
destinationDataTable.Rows.Add(clonedRow);
return clonedRow;
}


/// <summary>
/// Operation: Clone sourceRow by destinationDataTable
/// </summary>
static public DataRow Clone(this DataTable destinationDataTable,
DataRow sourceRow)
{
DataRow clonedRow = destinationDataTable.NewRow();
clonedRow.ItemArray = (object[])sourceRow.ItemArray.Clone();


return clonedRow;
}
}
}

I also faced the similar problem. I googled but couldn't find the solution. So I tried on my own and here is my solution.

Such renaming of upstream libraries is common; something such as apt-cache search libgdal can help locate the current package names. The important key though is that the "abstract" development package libgdal-dev is all that is needed to build as it pulls the "concrete" current run-time package (here: libgdal1i) in via a dependency.

Results

libgdal1-dev: /usr/bin/gdal-config

Simple solution which worked for me.

  1. Install Vim editor for windows.
  2. So I installed libgdal1-dev, as shown below:

    $ sudo apt-get install libgdal1-dev
    
  • Open VS 2012 project solution using Vim editor and modify the version targetting Visual studio solution 10.
  • Try this on CentOS 6

    sudo yum install gdal gdal-python gdal-devel mapserver mapserver-python libxml2 libxml2-python python-lxml python-pip python-devel gcc
    

    sudo apt-get install libgdal-dev

    ORA-01000, the maximum-open-cursors error, is an extremely common error in Oracle database development. In the context of Java, it happens when the application attempts to open more ResultSets than there are configured cursors on a database instance.

    Common causes are:

      If possible please read my answer for more understanding of my solution

    1. Configuration mistake

        number of cursors available for all schemas, users and sessions. When all cursors are open (in use) and request comes in that requires a new cursor, the request fails with an ORA-010000 error.

      • You have more threads in your application querying the database than cursors on the DB. One case is where you have a connection and thread pool larger than the number of cursors on the database.
      • Finding and setting the number of cursors

      • You have many developers or applications connected to the same DB instance (which will probably include many schemas) and together you are using too many connections.
      • Solution:

          The number is normally configured by the DBA on installation. The number of cursors currently in use, the maximum number and the configuration can be accessed in the Administrator functions in Oracle SQL Developer. From SQL it can be set with:

          ALTER SYSTEM SET OPEN_CURSORS=1337 SID='*' SCOPE=BOTH;
          
        • Increasing the number of cursors on the database (if resources allow) or
        • Relating JDBC in the JVM to cursors on the DB

        • Decreasing the number of threads in the application.
    2. The JDBC objects below are tightly coupled to the following database concepts:

      • Cursor leak

        • The applications is not closing ResultSets (in JDBC) or cursors (in stored procedures on the database)
        • JDBC Connection is the client representation of a database session and provides database transactions. A connection can have only a single transaction open at any one time (but transactions can be nested)
        • Solution: Cursor leaks are bugs; increasing the number of cursors on the DB simply delays the inevitable failure. Leaks can be found using static code analysis, JDBC or application-level logging, and database monitoring.

    Background

  • A JDBC ResultSet is supported by a single cursor on the database. When close() is called on the ResultSet, the cursor is released.
  • This section describes some of the theory behind cursors and how JDBC should be used. If you don't need to know the background, you can skip this and go straight to 'Eliminating Leaks'.

    What is a cursor?

  • A JDBC CallableStatement invokes a stored procedure on the database, often written in PL/SQL. The stored procedure can create zero or more cursors, and can return a cursor as a JDBC ResultSet.
  • A cursor is a resource on the database that holds the state of a query, specifically the position where a reader is in a ResultSet. Each SELECT statement has a cursor, and PL/SQL stored procedures can open and use as many cursors as they require. You can find out more about cursors on Orafaq.

    JDBC is thread safe: It is quite OK to pass the various JDBC objects between threads.

    For example, you can create the connection in one thread; another thread can use this connection to create a PreparedStatement and a third thread can process the result set. The single major restriction is that you cannot have more than one ResultSet open on a single PreparedStatement at any time. See Does Oracle DB support multiple (parallel) operations per connection?

    Note that a database commit occurs on a Connection, and so all DML (INSERT, UPDATE and DELETE's) on that connection will commit together. Therefore, if you want to support multiple transactions at the same time, you must have at least one Connection for each concurrent Transaction.

    A database instance typically serves several different schemas, many different users each with multiple sessions. To do this, it has a fixed number of cursors available for all schemas, users and sessions. When all cursors are open (in use) and request comes in that requires a new cursor, the request fails with an ORA-010000 error.

    Closing JDBC objects

    Finding and setting the number of cursors

    A typical example of executing a ResultSet is:

    Statement stmt = conn.createStatement();
    try {
    ResultSet rs = stmt.executeQuery( "SELECT FULL_NAME FROM EMP" );
    try {
    while ( rs.next() ) {
    System.out.println( "Name: " + rs.getString("FULL_NAME") );
    }
    } finally {
    try { rs.close(); } catch (Exception ignore) { }
    }
    } finally {
    try { stmt.close(); } catch (Exception ignore) { }
    }
    

    Note how the finally clause ignores any exception raised by the close():

    • If you simply close the ResultSet without the try {} catch {}, it might fail and prevent the Statement being closed
    • We want to allow any exception raised in the body of the try to propagate to the caller. If you have a loop over, for example, creating and executing Statements, remember to close each Statement within the loop.

    The number is normally configured by the DBA on installation. The number of cursors currently in use, the maximum number and the configuration can be accessed in the Administrator functions in Oracle SQL Developer. From SQL it can be set with:

    ALTER SYSTEM SET OPEN_CURSORS=1337 SID='*' SCOPE=BOTH;
    

    Relating JDBC in the JVM to cursors on the DB

    The JDBC objects below are tightly coupled to the following database concepts:

      In Java 7, Oracle has introduced the AutoCloseable interface which replaces most of the Java 6 boilerplate with some nice syntactic sugar.

      Holding JDBC objects

      JDBC objects can be safely held in local variables, object instance and class members. It is generally better practice to:

      • Use object instance or class members to hold JDBC objects that are reused multiple times over a longer period, such as Connections and PreparedStatements
      • JDBC Connection is the client representation of a database session and provides database transactions. A connection can have only a single transaction open at any one time (but transactions can be nested)
      • Use local variables for ResultSets since these are obtained, looped over and then closed typically within the scope of a single function.

      There is, however, one exception: If you are using EJBs, or a Servlet/JSP container, you have to follow a strict threading model:

      • A JDBC ResultSet is supported by a single cursor on the database. When close() is called on the ResultSet, the cursor is released.
      • Only the Application Server creates threads (with which it handles incoming requests)
      • Only the Application Server creates connections (which you obtain from the connection pool)
      • When saving values (state) between calls, you have to be very careful. Never store values in your own caches or static members - this is not safe across clusters and other weird conditions, and the Application Server may do terrible things to your data. Instead use stateful beans or a database.
      • A JDBC CallableStatement invokes a stored procedure on the database, often written in PL/SQL. The stored procedure can create zero or more cursors, and can return a cursor as a JDBC ResultSet.
    • In particular, never hold JDBC objects (Connections, ResultSets, PreparedStatements, etc) over different remote invocations - let the Application Server manage this. The Application Server not only provides a connection pool, it also caches your PreparedStatements.

    JDBC is thread safe: It is quite OK to pass the various JDBC objects between threads.

    Eliminating leaks

    For example, you can create the connection in one thread; another thread can use this connection to create a PreparedStatement and a third thread can process the result set. The single major restriction is that you cannot have more than one ResultSet open on a single PreparedStatement at any time. See Does Oracle DB support multiple (parallel) operations per connection?

    There are a number of processes and tools available for helping detect and eliminating JDBC leaks:

      Note that a database commit occurs on a Connection, and so all DML (INSERT, UPDATE and DELETE's) on that connection will commit together. Therefore, if you want to support multiple transactions at the same time, you must have at least one Connection for each concurrent Transaction.

    1. During development - catching bugs early is by far the best approach:

      1. Development practices: Good development practices should reduce the number of bugs in your software before it leaves the developer's desk. Specific practices include:

          Closing JDBC objects

          A typical example of executing a ResultSet is:

          Statement stmt = conn.createStatement();
          try {
          ResultSet rs = stmt.executeQuery( "SELECT FULL_NAME FROM EMP" );
          try {
          while ( rs.next() ) {
          System.out.println( "Name: " + rs.getString("FULL_NAME") );
          }
          } finally {
          try { rs.close(); } catch (Exception ignore) { }
          }
          } finally {
          try { stmt.close(); } catch (Exception ignore) { }
          }
          
        1. Pair programming, to educate those without sufficient experience
        2. Note how the finally clause ignores any exception raised by the close():

          • Code reviews because many eyes are better than one
          • Unit testing which means you can exercise any and all of your code base from a test tool which makes reproducing leaks trivial
          • If you simply close the ResultSet without the try {} catch {}, it might fail and prevent the Statement being closed
          • We want to allow any exception raised in the body of the try to propagate to the caller. If you have a loop over, for example, creating and executing Statements, remember to close each Statement within the loop.
        3. Use existing libraries for connection pooling rather than building your own
      2. Static Code Analysis: Use a tool like the excellent Findbugs to perform a static code analysis. This picks up many places where the close() has not been correctly handled. Findbugs has a plugin for Eclipse, but it also runs standalone for one-offs, has integrations into Jenkins CI and other build tools

    2. In Java 7, Oracle has introduced the AutoCloseable interface which replaces most of the Java 6 boilerplate with some nice syntactic sugar.

    3. At runtime:

        Holding JDBC objects

      1. Holdability and commit

          JDBC objects can be safely held in local variables, object instance and class members. It is generally better practice to:

          • If the ResultSet holdability is ResultSet.CLOSE_CURSORS_OVER_COMMIT, then the ResultSet is closed when the Connection.commit() method is called. This can be set using Connection.setHoldability() or by using the overloaded Connection.createStatement() method.
      2. Use object instance or class members to hold JDBC objects that are reused multiple times over a longer period, such as Connections and PreparedStatements
      3. Logging at runtime.

        1. Use local variables for ResultSets since these are obtained, looped over and then closed typically within the scope of a single function.
        2. Put good log statements in your code. These should be clear and understandable so the customer, support staff and teammates can understand without training. They should be terse and include printing the state/internal values of key variables and attributes so that you can trace processing logic. Good logging is fundamental to debugging applications, especially those that have been deployed.
        3. There is, however, one exception: If you are using EJBs, or a Servlet/JSP container, you have to follow a strict threading model:

          • Only the Application Server creates threads (with which it handles incoming requests)
          • You can add a debugging JDBC driver to your project (for debugging - don't actually deploy it). One example (I have not used it) is log4jdbc. You then need to do some simple analysis on this file to see which executes don't have a corresponding close. Counting the open and closes should highlight if there is a potential problem

            1. Only the Application Server creates connections (which you obtain from the connection pool)
            2. When saving values (state) between calls, you have to be very careful. Never store values in your own caches or static members - this is not safe across clusters and other weird conditions, and the Application Server may do terrible things to your data. Instead use stateful beans or a database.
            3. Monitoring the database. Monitor your running application using the tools such as the SQL Developer 'Monitor SQL' function or Quest's TOAD. Monitoring is described in this article. During monitoring, you query the open cursors (eg from table v$sesstat) and review their SQL. If the number of cursors is increasing, and (most importantly) becoming dominated by one identical SQL statement, you know you have a leak with that SQL. Search your code and review.
  • In particular, never hold JDBC objects (Connections, ResultSets, PreparedStatements, etc) over different remote invocations - let the Application Server manage this. The Application Server not only provides a connection pool, it also caches your PreparedStatements.
  • Other thoughts

    Can you use WeakReferences to handle closing connections?

    Eliminating leaks

    There are a number of processes and tools available for helping detect and eliminating JDBC leaks:

      Weak and soft references are ways of allowing you to reference an object in a way that allows the JVM to garbage collect the referent at any time it deems fit (assuming there are no strong reference chains to that object).

    1. During development - catching bugs early is by far the best approach:

        If you pass a ReferenceQueue in the constructor to the soft or weak Reference, the object is placed in the ReferenceQueue when the object is GC'ed when it occurs (if it occurs at all). With this approach, you can interact with the object's finalization and you could close or finalize the object at that moment.

        Phantom references are a bit weirder; their purpose is only to control finalization, but you can never get a reference to the original object, so it's going to be hard to call the close() method on it.

      1. Development practices: Good development practices should reduce the number of bugs in your software before it leaves the developer's desk. Specific practices include:

        1. Pair programming, to educate those without sufficient experience
        2. Code reviews because many eyes are better than one
        3. However, it is rarely a good idea to attempt to control when the GC is run (Weak, Soft and PhantomReferences let you know after the fact that the object is enqueued for GC). In fact, if the amount of memory in the JVM is large (eg -Xmx2000m) you might never GC the object, and you will still experience the ORA-01000. If the JVM memory is small relative to your program's requirements, you may find that the ResultSet and PreparedStatement objects are GCed immediately after creation (before you can read from them), which will likely fail your program.

        4. Unit testing which means you can exercise any and all of your code base from a test tool which makes reproducing leaks trivial
        5. TL;DR: The weak reference mechanism is not a good way to manage and close Statement and ResultSet objects.

  • Use existing libraries for connection pooling rather than building your own
  • On macOS

    brew install gdal

  • Static Code Analysis: Use a tool like the excellent Findbugs to perform a static code analysis. This picks up many places where the close() has not been correctly handled. Findbugs has a plugin for Eclipse, but it also runs standalone for one-offs, has integrations into Jenkins CI and other build tools

  • removed the error

  • At runtime:

      gdal-config not found

  • Holdability and commit

      The same problem occurred today to me on a Linux CentOS 6.10 on which I do not have administration rights.

    1. If the ResultSet holdability is ResultSet.CLOSE_CURSORS_OVER_COMMIT, then the ResultSet is closed when the Connection.commit() method is called. This can be set using Connection.setHoldability() or by using the overloaded Connection.createStatement() method.
  • What I did:

  • Logging at runtime.

      a) Create a conda environment dedicated to my R version

      conda create --name MYR
      
    1. Put good log statements in your code. These should be clear and understandable so the customer, support staff and teammates can understand without training. They should be terse and include printing the state/internal values of key variables and attributes so that you can trace processing logic. Good logging is fundamental to debugging applications, especially those that have been deployed.
    2. b) Activate the environment

      source activate MYR
      

      c) Install R

      conda install -c conda-forge r-base
      
    3. You can add a debugging JDBC driver to your project (for debugging - don't actually deploy it). One example (I have not used it) is log4jdbc. You then need to do some simple analysis on this file to see which executes don't have a corresponding close. Counting the open and closes should highlight if there is a potential problem

        d) Install libgdal

        conda install -c conda-forge libgdal
        

        This solved the problem for me. My R version was 4.1.3. I guess other versions should work.