Software caused connection abort: socket write error Again

Hello experts,

I have conclude that this exception happens becuase i use datasource mode in my applications and the database in the weekend is shut down for  the backup. so i need to restart the tomcat to initiate the connection again with the database.

is this logical ?

any way , i will ask to schedule database shutdown to re produce the error
Web_AdminAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Mick BarryJava DeveloperCommented:
that would make sense, if the database is shutdown your going to get exception trying to talk to it
0
Web_AdminAuthor Commented:
objects
i got the exception in the application using datasource mode which is database connection on the server level. if the server lost the connection due to the shutdown, i need to restart the server to initiate the connection

hope my boss will be happy with this conclusion :D
0
Web_AdminAuthor Commented:

I think if i change the connection to driver mode or pool mode won't get this exception.

what jdbc mode should i go for ?
0
Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

Mick BarryJava DeveloperCommented:
its more likely because you are using a connection pool
what you can do is configure the pool to validate a connection before using it and/or just create a new one if there is a failure reusing an existing one
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Web_AdminAuthor Commented:
objects:

so how i can do this? change in the configuration ?
0
Mick BarryJava DeveloperCommented:
possibly, depends on what connection  pool you are using
0
Web_AdminAuthor Commented:
i use this one:


<Resource name="jdbc/myoracle" auth="Container"
              type="javax.sql.DataSource" driverClassName="oracle.jdbc.OracleDriver"
              url="jdbc:oracle:thin:@127.0.0.1:1521:mysid"
              username="scott" password="tiger" maxActive="20" maxIdle="10"
              maxWait="-1"/>



	

Context initContext = new InitialContext();
Context envContext  = (Context)initContext.lookup("java:/comp/env");
DataSource ds = (DataSource)envContext.lookup("jdbc/myoracle");
Connection conn = ds.getConnection();

Open in new window

0
Mick BarryJava DeveloperCommented:
looks like you're not using a connection pool
does your application keep connections open? If so, then what you need to do when you get this exception is try and get a new connection. Though if the database is down you're going to need some logic so it doesn't sit there repeatedly trying to get a connection.
0
Pramod KumarCommented:
before using connection, you must check if it is open or closed


public Connection getConnection() {
	Context initContext = new InitialContext();
	Context envContext  = (Context)initContext.lookup("java:/comp/env");
	DataSource ds = (DataSource)envContext.lookup("jdbc/myoracle");
	Connection conn = ds.getConnection();
	return conn;
}
.
.
.
//before using the connection object
if(conn.isClosed()){
 conn = getConnection();
}

Open in new window

0
Web_AdminAuthor Commented:
Thanks
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java App Servers

From novice to tech pro — start learning today.