My error:
java.sql.SQLException: Listener refused the connection with the following error:
ORA-12516, TNS:listener could not find available handler with matching protocol
stack
The Connection descriptor used by the client was:
//10.2.5.21:9001/XE
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java
:112)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java
:261)
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:387)
at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:
414)
at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:165)
at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtensio
n.java:35)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:801)
at oracle.jdbc.pool.OracleDataSource.getPhysicalConnection(OracleDataSou
rce.java:297)
at oracle.jdbc.pool.OracleDataSource.getConnection(OracleDataSource.java
:221)
at oracle.jdbc.pool.OracleDataSource.getConnection(OracleDataSource.java
:165)
at utilityService.DB_util.setOracleConnectionActive(DB_util.java:99)
at utilityService.DB_util.getRecPreparedAuthentication(DB_util.java:124)
My common db connection class:
package utilityService;
import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import oracle.jdbc.pool.OracleDataSource;
public class DB_util {
String propValue = "";
ResultSet rec = null;
Statement stm = null;
PreparedStatement pre_stm = null;
CallableStatement call_stm = null;
Connection conn1 = null;
/**
* Constructure to get oracle connection
*/
public DB_util() {
Util util=new Util();
propValue=util.getFilePathToSave();
//propValue = Util.propValue;// get oracle connection
setOracleConnectionActive();
}
/**
* Close all oracle connections and result sets.
*/
public void setOracleConnectionClose() {
try {
if (conn1 != null || !conn1.isClosed()) {
if (rec != null) {
rec.close();
rec = null;
}
if (stm != null) {
stm.close();
stm = null;
}
if (pre_stm != null) {
pre_stm.close();
pre_stm = null;
}
if (call_stm != null) {
call_stm.close();
call_stm = null;
}
conn1.commit();
conn1.close();
conn1 = null;
}
} catch (Exception ex) {
ex.printStackTrace();
}
}
/**
* return a result set according to sql sent
*
* #param SQL
* #return
*/
public ResultSet getRec(String SQL) {
try {
setOracleConnectionActive();
stm = conn1.createStatement();
rec = stm.executeQuery(SQL);
return rec;
} catch (Exception ex) {
ex.printStackTrace();
return rec;
}
}
/**
* Activate oracle connection
*/
private void setOracleConnectionActive() {
try {
if (conn1 == null || conn1.isClosed()) {
OracleDataSource ods = new OracleDataSource();
if (propValue != null) {
ods.setURL(propValue);
}
conn1 = ods.getConnection();
System.out.println("DB connection CONNECTED......");
conn1.setAutoCommit(false);
}
} catch (Exception ex) {
//setOracleConnectionActive();
ex.printStackTrace();
System.out.println("DB connection FAILED......");
}
}
/**
* send prepared result set with user authenticate
*
* #param SQL
* #param strInputUserMobile
* #param strInputUserName
* #param strInputUserPassword
* #return
*/
public ResultSet getRecPreparedAuthentication(String SQL,
String strInputUserMobile, String strInputUserName,
String strInputUserPassword) {
try {
setOracleConnectionActive();
pre_stm = conn1.prepareStatement(SQL);
pre_stm.setString(1, strInputUserMobile);
pre_stm.setString(2, strInputUserName);
pre_stm.setString(3, strInputUserPassword);
rec = pre_stm.executeQuery();
return rec;
} catch (Exception ex) {
ex.printStackTrace();
return rec;
}
}
/**
* insert sql to db which is send as a sql
*
* #param SQL
* #return
*/
public int insertSQL(String SQL) {
int output = 0;
try {
setOracleConnectionActive();
stm = conn1.createStatement();
output = stm.executeUpdate(SQL);
conn1.commit();
output = 1;
} catch (Exception ex) {
try {
conn1.rollback();
output = 0;
} catch (SQLException e) {
e.printStackTrace();
output = 0;
}
ex.printStackTrace();
}
return output;
}
/**
* Send a callable statement according to sent sql
*
* #param SQL
* #return
*/
public CallableStatement callableStatementSQL(String SQL) {
int output = 0;
try {
setOracleConnectionActive();
call_stm = conn1.prepareCall(SQL);
} catch (Exception ex) {
try {
conn1.rollback();
output = 0;
} catch (SQLException e) {
e.printStackTrace();
output = 0;
}
ex.printStackTrace();
}
return call_stm;
}
}
Every transaction I refer this class and do my fetching & CRUD operations.
Is there any issue with my code?
You opened a lot of connections and that's the issue. I think in your code, you did not close the opened connection.
A database bounce could temporarily solve, but will re-appear when you do consecutive execution.
Also, it should be verified the number of concurrent connections to the database. If maximum DB processes parameter has been reached this is a common symptom.
Courtesy of this thread: https://community.oracle.com/thread/362226?tstart=-1
I fixed this problem with sql command line:
connect system/<password>
alter system set processes=300 scope=spfile;
alter system set sessions=300 scope=spfile;
Restart database.
For me the problem was not the number of connexions, but the "matching protocol" part. Changing the ojdbc version solved the problem.
Related
So I have a claim script that I'm trying to put together, that claims the product after purchase. The program is built inside of Java. The problem I'm running into is that there is a custom field they input on their purchase, and the store itself inserts it into a JSON format. So I need to execute a query that pulls the custom field into the WHERE statement, like so :
public class StoreClaim implements Runnable {
public static final String HOST = "104.161.43.58"; // website ip address
public static final String USER = "eseezjte_forum";
public static final String PASS = "Fishsticks123";
public static final String DATABASE = "eseezjte_forum";
private Player player;
private Connection conn;
private Statement stmt;
public StoreClaim(Player player) {
this.player = player;
}
public void run() {
try {
if (!connect(HOST, DATABASE, USER, PASS)) {
return;
}
String name = player.getUsername().replace("_", " ");
ResultSet connect = executeQuery("SELECT ps_claimed, ps_item_id, ps_custom_fields->$.1 AS claimed FROM nexus_purchases WHERE ps_custom_fields->$.1 = '"+name+"' AND ps_claimed='0'");
while (connect.next()) {
player.sm("WORKING!");
return;
}
destroy();
} catch (Exception e) {
e.printStackTrace();
}
}
/**
*
* #param host the host ip address or url
* #param database the name of the database
* #param user the user attached to the database
* #param pass the users password
* #return true if connected
*/
public boolean connect(String host, String database, String user, String pass) {
try {
this.conn = DriverManager.getConnection("jdbc:mysql://"+host+":3306/"+database, user, pass);
return true;
} catch (SQLException e) {
System.out.println("Failing connecting to database!");
return false;
}
}
/**
* Disconnects from the MySQL server and destroy the connection
* and statement instances
*/
public void destroy() {
try {
conn.close();
conn = null;
if (stmt != null) {
stmt.close();
stmt = null;
}
} catch(Exception e) {
e.printStackTrace();
}
}
/**
* Executes an update query on the database
* #param query
* #see {#link Statement#executeUpdate}
*/
public int executeUpdate(String query) {
try {
this.stmt = this.conn.createStatement(1005, 1008);
int results = stmt.executeUpdate(query);
return results;
} catch (SQLException ex) {
ex.printStackTrace();
}
return -1;
}
/**
* Executres a query on the database
* #param query
* #see {#link Statement#executeQuery(String)}
* #return the results, never null
*/
public ResultSet executeQuery(String query) {
try {
this.stmt = this.conn.createStatement(1005, 1008);
ResultSet results = stmt.executeQuery(query);
return results;
} catch (SQLException ex) {
ex.printStackTrace();
}
return null;
}
So i need to insert into this Result Set the JSON I'm trying to pull from.
This is what I'm trying to pull from the database and insert as the name to verify which user bought the product to claim.
I get the error :
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '>$.1 AS claimed FROM nexus_purchases WHERE ps_custom_fields->$.1 = 'quantum' ...' at line 1
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
at com.mysql.jdbc.Util.getInstance(Util.java:386)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1052)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3609)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3541)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2002)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2163)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2618)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2568)
at com.mysql.jdbc.StatementImpl.executeQuery(StatementImpl.java:1557)
at quantum.site.StoreClaim.executeQuery(StoreClaim.java:139)
at quantum.site.StoreClaim.run(StoreClaim.java:45)
at java.lang.Thread.run(Thread.java:748)
java.lang.NullPointerException
at quantum.site.StoreClaim.run(StoreClaim.java:46)
at java.lang.Thread.run(Thread.java:748)
which points to :
ResultSet connect = executeQuery("SELECT ps_claimed, ps_item_id, ps_custom_fields->$.1 AS claimed FROM nexus_purchases WHERE ps_custom_fields->$.1 = '"+name+"' AND ps_claimed='0'");
I need the execute to check the databse, find a row in which the name == the custom field "1": variable, and where claimed == 0, and I will need to pull the ps_item_id from that row to execute inside another file. How do i properly access the array and check if the player name is == to the "1": variable?
After trying multiple different ways, I found through JSON object how to parse the data. I had to initiate a first ResultSet, and than from that result set, pull the custom_field and than pull that into a JSON Object, parse the "1" to a string, and than use another ResultSet with that string to get that row
String name = player.getUsername().replace("_", " ");
ResultSet connect = executeQuery("SELECT * FROM nexus_purchases WHERE ps_claimed='0'");
while (connect.next()) {
String str = connect.getString("ps_custom_fields");
JSONObject obj = new JSONObject(str);
String n = obj.getString("1");
ResultSet check = executeQuery("SELECT * FROM nexus_purchases WHERE '"+n+"' = '"+name+"' AND ps_claimed='0'");
while (check.next()) {
player.sm("WORKING!");
return;
}
}
I'm working on an application that records do my MySql database on my server. Every time I want to use the database, get the existing connection, if not, I think for the first time. When I do an insert or select, works very well, but followed that consultation, when it ends, I can never regain the connection and do not return to consultations.
My class of Database
public class Database {
/**
* Gets just one instance of the class
* Connects on construct
* #returns connection
*/
private Connection _conn = null;
private long timer;
//singleton code
private static Database DatabaseObject;
private Database() {}
public static Database connect() {
if (DatabaseObject == null)
DatabaseObject = new Database();
return DatabaseObject._connect();
}
public Object clone() throws CloneNotSupportedException {
throw new CloneNotSupportedException();
}
//end singleton code
/**
* Connects with the defined parameters on Config
* Prevents re-connection if object was already connected
* #throws SQLException
*/
private Database _connect() {
try {
if (this._conn == null || !this._conn.isValid(0)) {
try {
Class.forName("com.mysql.jdbc.Driver");
Properties connProps = new Properties();
connProps.put("user", Config.Config.DB_USER);
connProps.put("password", Config.Config.DB_PASS);
this._conn = DriverManager.
getConnection("jdbc:" + Config.Config.DB_DBMS + "://" + Config.Config.DB_HOST + ":"
+ Config.Config.DB_PORT + "/" + Config.Config.DB_NAME, Config.Config.DB_USER, Config.Config.DB_PASS);
timer = System.currentTimeMillis();
} catch (ClassNotFoundException e) {
System.out.println("Where is your MySQL JDBC Driver?");
e.printStackTrace();
} catch (Exception e) {
System.out.println("Could not connect to DB");
e.printStackTrace();
}
} else {
try {
long tmp = System.currentTimeMillis() - timer;
if (tmp > 1200000) { //3600000 one hour ; 1200000 twenty minutes
System.out.println("Forcing reconnection ("+tmp+" milliseconds passed since last connection)");
this.close();
this._connect();
}
} catch (Exception e) {
e.printStackTrace();
System.out.println("Forcing reconnection");
this._conn = null;
this._connect();
}
}
} catch (Exception e) {
e.printStackTrace();
}
return this;
}
/**
* Closes connections
* This has to be invoked when database connection is no longer needed
* #throws SQLException
*/
public void close() throws SQLException {
if (this._conn != null) {
this._conn.close();
this._conn = null;
}
}
/**
* Getter for connection
* #return
*/
public Connection get() {
return this._conn;
}
}
The following function I make a query:
private Statement sment = null;
private PreparedStatement psment = null;
private ResultSet rset = null;
public boolean existsByNameAndUserId(String md5, int userId, int eventId) {
Connection conn = Database.connect().get();
try {
psment = conn.prepareStatement("SELECT * FROM files "
+ "WHERE user_id = ? AND md5 = ? AND evento_id = ?");
psment.setInt(1, userId);
psment.setString(2, md5);
psment.setInt(3, eventId);
rset = psment.executeQuery();
if (rset.next()) {
return true;
}
} catch (Exception e) {
e.printStackTrace();
}
return false;
}
private void close() {
try { if (rset != null) rset.close(); } catch (Exception e) {System.out.println(e.getMessage());};
try { if (psment != null) psment.close(); } catch (Exception e) {System.out.println(e.getMessage());};
try { if (sment != null) sment.close(); } catch (Exception e) {System.out.println(e.getMessage());};
}
And in the next, I call the above function to find out whether or not a record with these characteristics, if not, I do an insert.
String SQL_INSERT = "INSERT INTO files (evento_id, user_id, path, thumb, preview, width, height, md5, numero_corredor, created, modified) "
+ "VALUES (?,?,?,?,?,?,?,?,?,NOW(),NOW())";
public void save(List<components.File.Schema> files) throws SQLException {
try (
Connection conn = Database.connect().get();
PreparedStatement statement = conn.prepareStatement(SQL_INSERT);
) {
int i = 0;
for (components.File.Schema file : files) {
if(!existsByNameAndUserId(file.getMd5(), file.getUserId(), file.getEventId())){
statement.setInt(1, file.getEventId());
statement.setInt(2, file.getUserId());
statement.setString(3, file.getPath());
statement.setString(4, file.getPreview());
statement.setString(5, file.getThumb());
statement.setInt(6, file.getWidth());
statement.setInt(7, file.getHeight());
statement.setString(8, file.getMd5());
statement.setString(9, null);
statement.addBatch();
i++;
if (i % 1000 == 0 || i == files.size()) {
statement.executeBatch(); // Execute every 1000 items.
}
}
}
}
}
Your issue is due to the fact that you put Connection conn = Database.connect().get() in a try-with-resources statement which is what you are supposed to do but it closes your connection and when you call it again as the method _connect() doesn't have a valid test, it doesn't create a new connection. The valid test is this._conn == null || !this._conn.isValid(0), indeed in your original test you call this._conn.isValid(0) which will returns false in our context since the connection is closed so it won't create a new connection which is not what we want here.
Response Update: The second part of the problem is the fact that in the save method you call existsByNameAndUserId which closes the current connection, you should only close the statement and let the method save close the connection.
try {
Class.forName("org.apache.derby.jdbc.ClientDriver");
Connection con = DriverManager.getConnection("jdbc:derby://localhost:1527/gledi", "root", "root");
String sql = "SELECT MAX(NR) from ROOT.GLEDI";
PreparedStatement pst = con.prepareStatement(sql);
ResultSet rs = pst.executeQuery();
if (rs.next()) {
String nr1= rs.getString("MAX(NR)"); // here is the whole problem !!!!! how can i fix it
text.setText(nr1);
}
} catch (Exception e) {
}
Give it a name and look it up.
Is that column a String type or a number?
Empty catch blocks are wrong. Print or log the stack trace. You'll never know if an exception is thrown otherwise.
Sure you don't want select count(*) from root.gledi? This query looks wrong to me.
You don't close Connection, Statement, or ResultSet in a finally block, as you should.
You should encapsulate this code in a method and give it a Connection, not create it every time.
So little code, so many errors.
Here's how I might write it:
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
/**
* JdbcDemo
* #author Michael
* #link http://stackoverflow.com/questions/21205161/how-to-fix-a-db-probblem-in-java-with-derby-db/21205183#21205183
* #since 1/18/14 9:51 AM
*/
public class JdbcDemo {
private static final String SELECT_MAX_ROW_NUMBER = "SELECT MAX(NR) as maxnr from ROOT.GLEDI";
private Connection connection;
public JdbcDemo(Connection connection) {
this.connection = connection;
}
public String getMaxRowNumber() {
String maxRowNumber = "";
PreparedStatement ps = null;
ResultSet rs = null;
try {
ps = connection.prepareStatement(SELECT_MAX_ROW_NUMBER);
rs = ps.executeQuery();
while (rs.next()) {
maxRowNumber = rs.getString("maxnr");
}
} catch (Exception e) {
e.printStackTrace(); // better to log this.
maxRowNumber = "";
} finally {
close(rs);
close(ps);
}
return maxRowNumber;
}
// belongs in a database utility class
public static void close(Statement st) {
try {
if (st != null) {
st.close();
}
} catch (SQLException e) {
e.printStackTrace(); // better to log this
}
}
// belongs in a database utility class
public static void close(ResultSet rs) {
try {
if (rs != null) {
rs.close();
}
} catch (SQLException e) {
e.printStackTrace(); // better to log this
}
}
}
We're having some trouble finding out why we are getting an error message when creating a connection with DriverManager.
Here is our code
package Databank;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.List;
public class Connectie_Databank
{
//Eigenschappen databank
private String connectieString = "";
private Connection connectie = null;
private PreparedStatement prepStatement = null;
private Statement statement = null;
private ResultSet inhoudQuery = null;
//Inloggegevens PhpMyAdmin
private String gebruikersnaam, wachtwoord;
//Constructor met standaardinstellingen
public Connectie_Databank()
{
this.connectieString = "jdbc:mysql://localhost/groep2_festivals";
this.gebruikersnaam = "root";
this.wachtwoord = "";
}
//Constructor met nieuwe data
public Connectie_Databank(String connectionString, String gebruikersnaam, String wachtwoord)
{
this.connectieString = connectionString;
this.gebruikersnaam = gebruikersnaam;
this.wachtwoord = wachtwoord;
}
/**
* Deze methode zorgt ervoor dat er verbinding gemaakt wordt me de databank
*/
public void maakConnectie()
{
try
{
connectie = DriverManager.getConnection(connectieString, gebruikersnaam, wachtwoord);
}
catch(Exception e)
{
System.err.println("FOUTMELDING: " + e.getMessage());
}
}
public void voerQueryUit(String query, List<String> parameters)
{
try
{
if(parameters.size() > 0)
{
//Reden preparedStatement: geen SQL-Injectie!
prepStatement = connectie.prepareStatement(query);
//Lijst met parameters uitlezen om de preparedStatement op te vullen
for(int i=1; i<=parameters.size(); i++)
{
prepStatement.setString(i, parameters.get(i-1));
}
inhoudQuery = prepStatement.executeQuery();
}
else
{
statement = connectie.createStatement();
inhoudQuery = statement.executeQuery(query);
}
}
catch(Exception e)
{}
}
public ResultSet haalResultSetOp()
{
return inhoudQuery;
}
public void sluitConnectie()
{
//ConnectieString leegmaken en alle objecten die te maken hebben met de connectie sluiten
try
{
connectieString = "";
if(connectie != null)
{
connectie.close();
}
if(prepStatement != null)
{
prepStatement.close();
}
if(inhoudQuery != null)
{
inhoudQuery.close();
}
}
catch(Exception e)
{}
}
}
We call our connection class from within a JSP page like this:
<%
Connectie_Databank connectie;
ResultSet res;
connectie = new Connectie_Databank();
connectie.maakConnectie ();
List<String> lijstParams = new ArrayList<String>();
connectie.voerQueryUit ("SELECT * FROM festivals", lijstParams);
res = connectie.haalResultSetOp();
%>
This happens in the head of our page. The first time the page loads, we get an error "no suitable driver found for jdbc mysql" but when we refresh, the information we query is shown correctly.
So, we only get the one error message on first load, after that, no errors occur and everything works normally.
Can anyone help us?
First you need to load JDBC driver before connection
// Notice, do not import com.mysql.jdbc.*
// or you will have problems!
//Load Driver
try {
// The newInstance() call is a work around for some
// broken Java implementations
Class.forName("com.mysql.jdbc.Driver").newInstance();
} catch (Exception ex) {
// handle the error
}
con=DriverManager.getConnection(connectieString);
System.out.println ("Database connection established");
make sure you have mysql-connector-java-5.x.x-bin.jar on the classpath when you run your application.
This is the code i had written to save the data into the openoffice database.
but its giving error.i m not understanding y it is appearing.
package coop.data;
import java.sql.*;
/**
*
* #author spk
*/
public class Connectionsetting {
private static Connection con;
private static Statement sm;
private static ResultSet rs;
public static void close()
{
try
{
sm.close();
con.close();
}
catch(Exception e)
{
e.printStackTrace();
}
}
public void connection() {
String db_file_name_prefix = "/home/spk/Desktop/CooperHr/mydb.odb";
/*
If required change the file name if you are working in windows os
connection is in work
*/
try {
Class.forName("org.hsqldb.jdbcDriver");
System.out.println("Driver Found");
con=DriverManager.getConnection("jdbc:hsqldb:file"+db_file_name_prefix,"sa", "");
System.out.println("Connection Eshtablished");
// con.setAutoCommit(false);
sm=con.createStatement();
// sm = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
} catch (Exception e) {
e.printStackTrace();
}
}
public static int executeupdate(String query) {
//Execute & update block insert, update, delete statements
int bool = 0;
try {
bool=sm.executeUpdate(query);
} catch (Exception e) {
e.printStackTrace();
}
return bool;
}
public ResultSet executeQuery(String query) {
//Block Returns single resultset,,,sql statements such as sql select
ResultSet rs=null;
try {
rs = sm.executeQuery(query);
} catch (Exception e) {
e.printStackTrace();
}
return rs;
}
public boolean checkTableStatus(String tblName) {
String sql = "selec * from cat";
ResultSet rs=null;
boolean status = false;
int i = 0;
String allTableNames[] = new String[20];
try {
connection();
rs = sm.executeQuery(sql);
while (rs.next()) {
allTableNames[i] = rs.getString(0);
i++;
if (allTableNames[i].equals(tblName)) {
status = true;
break;
} else {
status = false;
break;
}
}
} catch (Exception e) {
e.printStackTrace();
}
return status;
}
public static void main(String []args)
{
String query,s1,s2,s3,s4,s5,s6,s7,s8;
Connectionsetting cn=new Connectionsetting();
cn.connection();
s1="same";
s2="sam";
s3="923847";
s4="sam";
s5="sam";
s6="sam";
s7="sam";
s8="R01";
query="insert into Agency_Master values("+s1+","+s2+","+s3+","+s4+","+s5+","+s6+","+s7+","+s8+")";
cn.executeupdate(query);
}
}
This is the error..I m getting it when i trying to save the data into the database
Can any one plz tell me where i m wrong.
Thank you.
run:
Driver Found
Connection Eshtablished
java.sql.SQLException: user lacks privilege or object not found: AGENCY_MASTER
at org.hsqldb.jdbc.Util.sqlException(Util.java:200)
at org.hsqldb.jdbc.JDBCStatement.fetchResult(JDBCStatement.java:1805)
at org.hsqldb.jdbc.JDBCStatement.executeUpdate(JDBCStatement.java:205)
at coop.data.Connectionsetting.executeupdate(Connectionsetting.java:52)
at coop.data.Connectionsetting.main(Connectionsetting.java:116)
Caused by: org.hsqldb.HsqlException: user lacks privilege or object not found: AGENCY_MASTER
at org.hsqldb.Error.error(Error.java:76)
at org.hsqldb.SchemaManager.getTable(SchemaManager.java:510)
at org.hsqldb.ParserDQL.readTableName(ParserDQL.java:4367)
at org.hsqldb.ParserDML.compileInsertStatement(ParserDML.java:64)
at org.hsqldb.ParserCommand.compilePart(ParserCommand.java:132)
at org.hsqldb.ParserCommand.compileStatements(ParserCommand.java:83)
at org.hsqldb.Session.executeDirectStatement(Session.java:1037)
at org.hsqldb.Session.execute(Session.java:865)
at org.hsqldb.jdbc.JDBCStatement.fetchResult(JDBCStatement.java:1797)
... 3 more
BUILD SUCCESSFUL (total time: 0 seconds)
Your connection URL looks iffy... try changing:
con=DriverManager.getConnection("jdbc:hsqldb:file"+db_file_name_prefix,"sa", "");
to
con=DriverManager.getConnection("jdbc:hsqldb:file:"+db_file_name_prefix+";ifexists=true","sa", "");
(adding a colon after "file", and appending the ifexists=true flag, as indicated by: http://hsqldb.org/doc/guide/ch04.html
It looks to me like the AGENCY_MASTER table doesn't exist. You're trying to execute an update statement, and it looks like HSQLDB can't find the AGENCY_MASTER table.
You can check whether the table exists with HSQLDB's built-in client/viewer:
java -cp hsqldb.jar org.hsqldb.util.DatabaseManagerSwing