jdbc

JPA build entity manager with a specific JDBC connection instance

I want to manage the database connection outside entity manager context so that I can use it for different entity managers. The question is how can I build the entity manager factory or entity manager with my own connection instead of providing it with properties in persistence.xml? ...

architecture mismatch between the Driver and Application?

I am using JDBC to connect to my microsoft access database. I get the following exception when I try to connect to the database: java.sql.SQLException: [Microsoft][ODBC Driver Manager] The specified DSN contains an architecture mismatch between the Driver and Application I am using 64bit windows7, and I am using eclipse which is al...

JDBC opening a new database session

I just want to make sure that if I use the following, I am opening a separate DB session and not resuing the same one (for testing I need individual sessions). Connection connection = DriverManager.getConnection(URL,USER,PASSWORD); each time I do the above code, I run my query, then do a connection.close() So for example: while(some...

Connecting to Teradata via PHP

We need to access a Teradata database via php application We don't have odbc (unixodbc etc) on the server. How might one go about connecting to a teradata database quickly. Keep in mind - this app needs to be as portable as possible. ...

Using PHP can I use a JDBC or ODBC connection?

I have a PHP application that I want to switch from MySQL to Cache DB. I was wondering if I could somehow use a JDBC or ODBC connection since Cache doesn't come with a PHP connection? Thanks ...

Where to store a DataSource resource in a Java web app?

This is a rookie question. What's the best place to put @Resource private DataSource ds; in a web application? Do I put it in a servlet, context listener or maybe there's a better place for it? Also, do I create a new Connection object in my doGet()/doPost() or should I do it somewhere else? What's the best practice for stuff like thi...

Where to create a prepared statement with JDBC?

Consider to following method that read data from some data-structure (InteractionNetwork) and writes them to a table in an SQLite database using an SQLite-JDBC dirver: private void loadAnnotations(InteractionNetwork network) throws SQLException { PreparedStatement insertAnnotationsQuery = connection.prepareStatement( ...

Is there a 64bit driver for Microsoft Access?

java.sql.SQLException: [Microsoft][ODBC Driver Manager] The specified DSN contains an architecture mismatch between the Driver and Application I get the following error when I try to connect to my Microsoft Access database from an eclipse project using jdbc. I am using 64bit windows and microsoft office 2007. any help on this matt...

In a JDBC ResultSet, what should happen when getLong() or getShort() is called on an int result column?

Say that I have a JDBC ResultSet, and I call the getLong() or getshort() method. For which of the following SQL types {SMALLINT, INT, BIGINT} should I get long, and for which types should I get an error? In other words, if I have an INT and I want a SMALLINT (A short), would I get it, or would I get an error? Similarly, if I have an ...

How to get hibernate3-maven-plugin hbm2ddl to find JDBC driver?

I have a Java project I am building with Maven. I am now trying to get the hibernate3-maven-plugin to run the hbm2ddl tool to generate a schema.sql file I can use to create the database schema from my annotated domain classes. This is a JPA application that uses Hibernate as the provider. In my persistence.xml file I call out the mysq...

Encoding problem wirh JDBC and MySQL

I'm grabbing data from RSS-channels, sanitize it and save in the database. I use java, tidy, MySQL and JDBC. Steps: I grab RSS-records. It's OK. I sanitize html with tidy. Here is one transformation. Tidy automatically converts strings like "So it’s unlikely" to "So it’s unlikely". I save this string to the table MySQL scheme ...

Is it possible to create a jdbc connection without a password (using postgresql 'trust')?

I am using jdbc to connect to a postgresql database in a java application (actually the app is written in Groovy). I have postgresql set up to use the 'trust' authentication method. Is it possible to open a jdbc connection without specifying a password? When I try to use the normal constructor with a blank password, it fails with Ex...

jdbc connection pooling

Can anybody provide examples or links on how to establish a JDBC connection pool? From searching google I see many different ways of doing this and it is rather confusing. Ultimately I need the code to return a java.sql.Connection object, but I am having trouble getting started..any suggestions welcome. Update: Doesn't javax.sql or j...

Java connectivity with MySQL

Can anyone explain me how to connect Java with MySQL? ...

java connectivity with mysql error

I just started with the connectivity and tried this example. I have installed the necessary softwares. Also copied the jar file into the /ext folder.Yet the code below has the following error import java.sql.*; public class Jdbc00 { public static void main(String args[]){ try { Statement stmt; Class.forName(...

Eclipse Data Source Explorer and MS-Access

I can't see any of my schemas when I try to use Eclipse data source explorer. It's not a problem with JDBC connection because I can connect and execute SQL statements. It's just that the tables don't appear. How do I make them to appear? ...

sql query to incrementally modify where condition until result contains what is required

I need an sql query to select some items from a table based on some condition which is based on a category field. As an example consider a list of people and I fetch the people from a particular age group from the database. I want to check if the result contains at least one result from each of a number of categories. If not I want to mo...

Java: Help constructing a fillTextFields() method

I have a Java project where I am to connect to a database and create buttons (next, new, save, delete, previous) to navigate through the database content where there are appropriate text fields and labels for the specific information. I'll use the code below as an example (each button is set up very similar)... I have it as follows: JB...

add database Tablenames to the JList in java

// Declare JList private JList jlstTab, jlstCol; . . . DefaultListModel dlmTables = new DefaultListModel(); DefaultListModel dlmCol = new DefaultListModel(); // Instantiate dlmTables.addElement("kl"); jlstTab= new JList(dlmTables); jlstTab.setSelectedIndex(0); jlstTab.setSelectionMode(ListSelectionM...

select for update problem in jdbc

I'm having a problem with select for update in jdbc. The table i'm trying to update is the smalldb table, i'm having problems-- i'm using select for update which does a lock on the selected row the update statement is -- String updateQ = "UPDATE libra.smalldb SET hIx = ? WHERE name = ?"; the select statement is -- rs = stmt1.execut...