Win a copy of Practice Tests for OCP Java 17 Certification Exam (1Z0-829) this week in the OCPJP forum!

arjun gaur

Ranch Hand
+ Follow
since Mar 01, 2014
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by arjun gaur

this is my table ::

create table User1(Username varchar2(20) ,
First_Name varchar2(20) ,
Last_Name varchar2(20) ,
Password varchar2(20) ,
Date_Of_Birth Date )


Hey! i have this code but i'm getting
i edited my code,made the changes but now i'm getting error-unreported exception ClassNotFounfException must be caught or declared to be thrown Class.forName("oracle.jdbc.OracleDriver")

same error for st.close() , ps.close() and rs.close()




Please help
Thanks
I have a combo box that specifies time in the form : 07:00,09:15 so on..
i have table in oracle database:
create table Appointment(
App_ID number primary key,
Doctor_ID number,
Patient_ID number,
App_Date Date,
App_Time TIMESTAMP,
App_Charges number);
now i want to convert the App_Time from combo box to TIMESTAMP to store in database..
Please help me what to do.
Hey! i managed to connect to the Oracle databas for express edition
I created a table :
create table Out_Patient(Patient_ID number(8) primary key ,First_Name varchar2(20) , Last_Name varchar2(20) ,Gender varchar2(10) , Mobile_Number number(12) , Address varchar2(20), Date_Of_Birth Date , Date_Of_Entry Date)
Now i have a form to fill up all these details but,i'm getting an sqlexception: ORA-01861:literals does not match format string
Can you tell what's causing it.am i entering data in wrong format ? I guess it might be due to 2 dates Date_Of_Birth and Date_Of_Entry.
in my JDBC code i'm doing this
String t1=text_dob.getText(); String t2=text_doe.getText();
and then
st.setStrin(7,t1);
st.setString(8,t2);
Please let me know what i'm doing wrong.
Thanks..
Looked up everywhere.but couldn't figure out what to do
still getting that TNs listener error.
looked into my listener.ora there sid_name=PLSExtProc
so i even tried this
Connection con=DriverManager.getConnection("jdbc : oracle : thin : @localhost : 1521 : PLSExtProc", "hr", "hr");
Now getting the error :"listenere failed to start a dedicated server process"
I edited my post please read it again..
i made the changes to SID ,i found out somewhere that by default SID for oracle express edition is XE,i changed to it still getting the error
Thanks
Hey!
I downloaded ojdbc14.jar,included it in the classpath
made the following changes:

Class.forName ("oracle.jdbc.OracleDriver");
Connection con = DriverManager.getConnection ("jdbc : oracle : thin : hr/hr@myhost : 1521 : orcl");

username:hr
password:hr
I'v created the table in Oracle express Edition 10g ,logged in.
i'm getting java.sql.SQLException:the network adapter could not establish connection.
Please help.
I'm not sure about that line in url "@myhost : 1521 : orcl" , i just copied it from oracle site.



I even tried :
Connection con = DriverManager.getConnection ("jdbc : oracle : thin : hr/hr@localhost : 1521 : orcl");
Connection con = DriverManager.getConnection ("jdbc : oracle : thin : hr/hr@localhost : 1521 : XE");
But it's saying "Listener does not currently know of SID given in connect descriptor"
Please help
Thanks
Yeah!! i read it

This is the stacktrace,can you figure out what is the problem ??

D:\m28>java Modify_appointment
error java.sql.SQLException: General error
java.sql.SQLException: General error
at sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:6993)
at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:7121)
at sun.jdbc.odbc.JdbcOdbc.SQLExecute(JdbcOdbc.java:3156)
at sun.jdbc.odbc.JdbcOdbcPreparedStatement.execute(JdbcOdbcPreparedState
ment.java:215)
at sun.jdbc.odbc.JdbcOdbcPreparedStatement.executeUpdate(JdbcOdbcPrepare
dStatement.java:137)
at Modify_appointment.actionPerformed(Modify_appointment.java:188)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:20
18)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.jav
a:2341)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel
.java:402)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259
)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonL
istener.java:252)
at java.awt.Component.processMouseEvent(Component.java:6505)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3320)
at java.awt.Component.processEvent(Component.java:6270)
at java.awt.Container.processEvent(Container.java:2229)
at java.awt.Component.dispatchEventImpl(Component.java:4861)
at java.awt.Container.dispatchEventImpl(Container.java:2287)
at java.awt.Component.dispatchEvent(Component.java:4687)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4832
)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4492)

at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4422)
at java.awt.Container.dispatchEventImpl(Container.java:2273)
at java.awt.Window.dispatchEventImpl(Window.java:2719)
at java.awt.Component.dispatchEvent(Component.java:4687)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:735)
at java.awt.EventQueue.access$200(EventQueue.java:103)
at java.awt.EventQueue$3.run(EventQueue.java:694)
at java.awt.EventQueue$3.run(EventQueue.java:692)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDo
main.java:76)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDo
main.java:87)
at java.awt.EventQueue$4.run(EventQueue.java:708)
at java.awt.EventQueue$4.run(EventQueue.java:706)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDo
main.java:76)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:705)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThre
ad.java:242)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.
java:161)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThre
ad.java:150)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146)

at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)

at java.awt.EventDispatchThread.run(EventDispatchThread.java:91)
Sorry for the above post.Posted at the wrong place..
8 years ago
This is the stacktrace,can you figure out what is the problem ??

D:\m28>java Modify_appointment
error java.sql.SQLException: General error
java.sql.SQLException: General error
at sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:6993)
at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:7121)
at sun.jdbc.odbc.JdbcOdbc.SQLExecute(JdbcOdbc.java:3156)
at sun.jdbc.odbc.JdbcOdbcPreparedStatement.execute(JdbcOdbcPreparedState
ment.java:215)
at sun.jdbc.odbc.JdbcOdbcPreparedStatement.executeUpdate(JdbcOdbcPrepare
dStatement.java:137)
at Modify_appointment.actionPerformed(Modify_appointment.java:188)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:20
18)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.jav
a:2341)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel
.java:402)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259
)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonL
istener.java:252)
at java.awt.Component.processMouseEvent(Component.java:6505)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3320)
at java.awt.Component.processEvent(Component.java:6270)
at java.awt.Container.processEvent(Container.java:2229)
at java.awt.Component.dispatchEventImpl(Component.java:4861)
at java.awt.Container.dispatchEventImpl(Container.java:2287)
at java.awt.Component.dispatchEvent(Component.java:4687)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4832
)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4492)

at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4422)
at java.awt.Container.dispatchEventImpl(Container.java:2273)
at java.awt.Window.dispatchEventImpl(Window.java:2719)
at java.awt.Component.dispatchEvent(Component.java:4687)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:735)
at java.awt.EventQueue.access$200(EventQueue.java:103)
at java.awt.EventQueue$3.run(EventQueue.java:694)
at java.awt.EventQueue$3.run(EventQueue.java:692)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDo
main.java:76)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDo
main.java:87)
at java.awt.EventQueue$4.run(EventQueue.java:708)
at java.awt.EventQueue$4.run(EventQueue.java:706)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDo
main.java:76)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:705)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThre
ad.java:242)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.
java:161)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThre
ad.java:150)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146)

at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)

at java.awt.EventDispatchThread.run(EventDispatchThread.java:91)
8 years ago
and for registering
Class.forName ("oracle . jdbc . OracleDriver");
i searched for it and i got the following results

Connection conn = DriverManager.getConnection
("jdbc : oracle : oci8 : scott/tiger@myhost);

Connection conn = DriverManager.getConnection
("jdbc : oracle : thin:scott/tiger@myhost:1521 : orcl);

My username :hr password:hr
but i don't know about "oci8" @myhost : 1521 : orcl etc in the above lines
right now i'm not using javaFX app .so ok i'll remove that jar file and add ojdbc14.jar.
what about driver name and Connection url.you said i'v to make changes in these cases.So what should i write ?
I guess the following lines need to be modified:
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:Hospital");
So tell me what should i change
Thanks..
Sorry for reposting ,i didn't see the replies in other post,
I know i used jdbc/odbc but now i'm changing it as i'v already posted queries about in JDBC forum.
And appointment table is like this
App_ID Auto number
Doctor_id Number
Patient_ID Number
App_date Date/Time
App_Time Date/Time
App_charges Number
And you said about converting text int java.util.date and then to java.sql.Date ,well i'm using the same table and i'm able to Insert the data into it without converting,so i cannot understand why that should be the problem in this case.
And folowing lines shows that App_time is getting the values from a Combo box.and iv coverted it into String using toString() and set the value using setString()
String s1=combo_time.getSelectedItem().toString();
st.setString(5,s1);

Thanks.
i downloaded the driver so what do i need to do..
1) include the jar file in my classpath.but i have already includede the javaFX jar file
.;C:\Program Files\Java7\jdk1.7.0_51\jre\lib\jfxrt.jar
So should i remove that one or simply add the ojdbc14.rar after it..
And what changes to be made in Connection URL and driver class name.
Thanks