prbhugra11
asked on
A question on Environment Variables and Reading a autoNumber from Database
Hi Everybody,
I need to set two variables as env variables.
viz. DMV_CONNECT which is the connect string to my database.
and DMV_FILE which is a filename.
I would like to know how to set these as env variables, and after having done this, how to read it into my java program.
The other thing is that i need to enter something into a database, which has the first column as an autonumber. The moment i do the insert, i would like to know the value assigned by this autonumber. How do i find this out.?
Thanks in advance.
I need to set two variables as env variables.
viz. DMV_CONNECT which is the connect string to my database.
and DMV_FILE which is a filename.
I would like to know how to set these as env variables, and after having done this, how to read it into my java program.
The other thing is that i need to enter something into a database, which has the first column as an autonumber. The moment i do the insert, i would like to know the value assigned by this autonumber. How do i find this out.?
Thanks in advance.
2) post ur code
or maybe its Q for DB topic area?
or maybe its Q for DB topic area?
2)
25. There is a method getColumnCount in the JDBC API. Is there a similar method to find the number of rows in a result set?
No, but it is easy to find the number of rows. If you are using a scrollable result set, rs, you can call the methods rs.last and then rs.getRow to find out how many rows rs has. If the result is not scrollable, you can either count the rows by iterating through the result set or get the number of rows by submitting a query with a COUNT column in the SELECT clause.
also look
http://tactika.com/realhome/javaht/java-d1.html
http://codeguru.developer.com/java/Miscellaneous/Database/index.shtml
http://java.sun.com/docs/books/jdbc/intro.html
http://java.sun.com/products/jdbc/faq.html
25. There is a method getColumnCount in the JDBC API. Is there a similar method to find the number of rows in a result set?
No, but it is easy to find the number of rows. If you are using a scrollable result set, rs, you can call the methods rs.last and then rs.getRow to find out how many rows rs has. If the result is not scrollable, you can either count the rows by iterating through the result set or get the number of rows by submitting a query with a COUNT column in the SELECT clause.
also look
http://tactika.com/realhome/javaht/java-d1.html
http://codeguru.developer.com/java/Miscellaneous/Database/index.shtml
http://java.sun.com/docs/books/jdbc/intro.html
http://java.sun.com/products/jdbc/faq.html
2)
25. There is a method getColumnCount in the JDBC API. Is there a similar method to find the number of rows in a result set?
No, but it is easy to find the number of rows. If you are using a scrollable result set, rs, you can call the methods rs.last and then rs.getRow to find out how many rows rs has. If the result is not scrollable, you can either count the rows by iterating through the result set or get the number of rows by submitting a query with a COUNT column in the SELECT clause.
also look
http://tactika.com/realhome/javaht/java-d1.html
http://codeguru.developer.com/java/Miscellaneous/Database/index.shtml
http://java.sun.com/docs/books/jdbc/intro.html
http://java.sun.com/products/jdbc/faq.html
25. There is a method getColumnCount in the JDBC API. Is there a similar method to find the number of rows in a result set?
No, but it is easy to find the number of rows. If you are using a scrollable result set, rs, you can call the methods rs.last and then rs.getRow to find out how many rows rs has. If the result is not scrollable, you can either count the rows by iterating through the result set or get the number of rows by submitting a query with a COUNT column in the SELECT clause.
also look
http://tactika.com/realhome/javaht/java-d1.html
http://codeguru.developer.com/java/Miscellaneous/Database/index.shtml
http://java.sun.com/docs/books/jdbc/intro.html
http://java.sun.com/products/jdbc/faq.html
Create Properties file and add them to propeties file.
and get the property whenever necessary.
Properties class is in java.util. package.
Best of luck
Hi prbhugra11,
For the other question you asked,
Create a program stored in database, that
(1) Inserts a row into the table
with the values passed from the
java program.
(2) Returns the number populated
in the first column.
For autonumbering, create a trigger on the
table in which you are inserting such that
it fires while inseting and populates the
first field from a sequence.
The merit of this approach is that you dont
have to access database twice - once for
inserting and second time for checking the
autonumber generated.
- Vish
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You can define your own properties through Properties() class
g_senthilkumar - may be better post comments ?
prbhugra11 - waiting for ur comments
prbhugra11 - waiting for ur comments
Getting System Properties
http://java.sun.com/docs/books/tutorial/applet/practical/properties.html
System.getProperties
public static Properties getProperties()
Determines the current system properties.
If there is a security manager, its checkPropertiesAccess method is called with no arguments. This may result in a security exception.
The current set of system properties is returned as a Properties object. If there is no current set of system properties, a set of system properties is first created and initialized.
This set of system properties always includes values for the following keys: Key Description of Associated Value
java.version Java version number
java.vendor Java vendor-specific string
java.vendor.url Java vendor URL
java.home Java installation directory
java.class.version Java class format version number
java.class.path Java class path
os.name Operating system name
os.arch Operating system architecture
os.version Operating system version
file.separator File separator ("/" on UNIX)
path.separator Path separator (":" on UNIX)
line.separator Line separator ("\n" on UNIX)
user.name User's account name
user.home User's home directory
user.dir User's current working directory
Exceptions
SecurityException if the current thread cannot access the system properties.
or u can use JNI
http://java.sun.com/docs/books/tutorial/native1.1/index.html
http://www.pbs.mcp.com/ebooks/1575211025/ch30.htm
http://www.sys-con.com/java/iss1/javan.htm
http://bogart.sip.ucm.es/demos/javawn/native.html
http://developer.netscape.com/viewsource/
also u can write a custom java wrapper using JNI_CreateJavaVM.