Imam problem sa izvrsavanjem sql-a
Code:
select * from sessions ses
left join korisnici using (id_korisnika)
where session_id = 'neki-session-id';
select * from sessions ses
left join korisnici using (id_korisnika)
where session_id = 'neki-session-id';
greska koja se javlja je: SQLException: Invalid column name .. ali je ustvari veci problem sto se greska ne javlja uvek.
Code:
CachedRowSetImpl crs = null;
try {
sqlstr = "SELECT * FROM sessions ses "
+ "LEFT JOIN korisnici kor USING (id_korisnika) "
+ "WHERE ses.session_id = '" + session_id + "' ";
crs = db.executeQuery(sqlstr, 0);
crs.last();
int broj_slogova = crs.getRow();
if (broj_slogova == 0) {
return "BEZ_PRIJAVE|-";
}
str_check_time = crs.getString("check_time"); <<< zvekete!!
.....
} catch (SQLException ex) {
System.out.println("[" + new java.util.Date() + "]\nSQLException: " + ex.getMessage()
}
/////////////
/// class db
/////////////
public static CachedRowSetImpl executeQuery(String query, int tip) {
Connection conn = null;
Statement st = null;
ResultSet rs = null;
try
{
conn = getConnection();
switch (tip)
{
case 0://SELECT
st = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);
rs = st.executeQuery(query);
crs = new CachedRowSetImpl();
crs.populate(rs);
break;
default://INSERT, UPDATE, or DELETE
st = conn.createStatement();
st.executeUpdate(query);
break;
}
} catch (SQLException ex)
{
System.out.println("[" + new java.util.Date() + "] GRESKA PRILIKOM IZVRSAVANJA SQL UPITA!\n" + query +"\nOPIS GRESKE:\n"+ ex);
}
try
{
if (st != null)
{
st.close();
}
if (rs != null)
{
rs.close();
}
if (conn != null)
{
freeConnection(conn);
}
} catch (Exception e)
{
e.printStackTrace();
}
return crs;
}
public static synchronized void freeConnection(Connection connection) {
try
{
if (connection != null)
{
connection.close();
}
connection = null;
} catch (Exception e)
{
System.err.println("DBBroker: Threw an exception closing a database connection");
e.printStackTrace();
}
}
CachedRowSetImpl crs = null;
try {
sqlstr = "SELECT * FROM sessions ses "
+ "LEFT JOIN korisnici kor USING (id_korisnika) "
+ "WHERE ses.session_id = '" + session_id + "' ";
crs = db.executeQuery(sqlstr, 0);
crs.last();
int broj_slogova = crs.getRow();
if (broj_slogova == 0) {
return "BEZ_PRIJAVE|-";
}
str_check_time = crs.getString("check_time"); <<< zvekete!!
.....
} catch (SQLException ex) {
System.out.println("[" + new java.util.Date() + "]\nSQLException: " + ex.getMessage()
}
/////////////
/// class db
/////////////
public static CachedRowSetImpl executeQuery(String query, int tip) {
Connection conn = null;
Statement st = null;
ResultSet rs = null;
try
{
conn = getConnection();
switch (tip)
{
case 0://SELECT
st = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);
rs = st.executeQuery(query);
crs = new CachedRowSetImpl();
crs.populate(rs);
break;
default://INSERT, UPDATE, or DELETE
st = conn.createStatement();
st.executeUpdate(query);
break;
}
} catch (SQLException ex)
{
System.out.println("[" + new java.util.Date() + "] GRESKA PRILIKOM IZVRSAVANJA SQL UPITA!\n" + query +"\nOPIS GRESKE:\n"+ ex);
}
try
{
if (st != null)
{
st.close();
}
if (rs != null)
{
rs.close();
}
if (conn != null)
{
freeConnection(conn);
}
} catch (Exception e)
{
e.printStackTrace();
}
return crs;
}
public static synchronized void freeConnection(Connection connection) {
try
{
if (connection != null)
{
connection.close();
}
connection = null;
} catch (Exception e)
{
System.err.println("DBBroker: Threw an exception closing a database connection");
e.printStackTrace();
}
}
Kao sto sam napomenu, program radi dobro .. ali se svremena na vreme pojavi u logu ovaj sql exception.
Jel ima neko neki predlog?
Hvala.