AKHILESH MISHRA IN OCEAN OF JAVA

Ocean Of Java

Wednesday, January 2, 2008

ora-12638 credential retrieval failed (while connecting oracle from client)

Please check the sqlnet.ora file. Change the following entry and try, this will work.Original Entry - SQLNET.AUTHENTICATION_SERVICES= (NTS)Modified Entry - SQLNET.AUTHENTICATION_SERVICES= (NONE)

Now it's working fine.

Saturday, October 27, 2007

Tuesday, July 3, 2007

Once Oracle was not getting startup

SQL> CREATE spfile FROM pfile='init.ora';

Tuesday, May 22, 2007

Zip any file

The java program to zip any number of files.


import java.util.zip.*;
import java.io.*;

public class JavaZip
{

public static void main(String[] ak)
{

// These are the files to include in the ZIP file
String[] filenames = new String[]{ak[0]};

// Create a buffer for reading the files
byte[] buf = new byte[1024];

try {
// Create the ZIP file
String outFilename = "c:/Akhilesh/java/project/"+ak[0]+".zip";
ZipOutputStream out = new ZipOutputStream(new FileOutputStream(outFilename));

// Compress the files
for (int i=0; i FileInputStream in = new FileInputStream(filenames[i]);

// Add ZIP entry to output stream.
out.putNextEntry(new ZipEntry(filenames[i]));

// Transfer bytes from the file to the ZIP file
int len;
while ((len = in.read(buf)) > 0) {
out.write(buf, 0, len);
}

// Complete the entry
out.closeEntry();
in.close();
}

// Complete the ZIP file
out.close();
} catch (IOException e) {
}
}
}
Copy and paste the program, compile program passing the files location, and run.

Convert .xls into .txt

The following java program is intended to convert .xls file into .txt file. This is simple java program which uses only java API.

import java.sql.*;
import java.util.*;
import java.io.*;

public class DataConversion
{
public static void main(String[] ak)
{
FileOutputStream fos;
PrintStream p;
try{
//String query="Select * from CCAPS_APP_REJECT_REASONS where rownum<='100'";
String query="SELECT * FROM [Sheet1$]";
//Class.forName("oracle.jdbc.driver.OracleDriver");
//Connection con = DriverManager.getConnection("jdbc:oracle:thin:@10.94.191.142:1521:testdata", "user", "password");

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:XLDSN","","");
Statement st=con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
ResultSet rst=st.executeQuery(query);

fos= new FileOutputStream("myfile.txt");
p=new PrintStream(fos);

ResultSetMetaData rsmd = rst.getMetaData();
int Columns = rsmd.getColumnCount();

while(rst.next())
{

for(int i=1;i<=Columns;i++)
{

if((rst.getString(i))==null)
{
p.print("\"\",");
/*if(i==15)
{
for(int j=1;j<16;j++)
{
p.print(",\"\"");
}
}
else if(i==16)
{

for(int j=1;j<4;j++)
{
p.print(",\"\"");
}
}*/

}

else
{
p.print("\""+rst.getString(i)+"\""+",");


}
}
p.println("\n");
}




//p.println("No. of column="+Columns);
}
catch (Exception ex)
{
ex.printStackTrace();
}
}
}

To run this program simply copy and paste on any location, create DSN by name 'XLDSN', create an excel file with some entry, compile the java file and run.

Saturday, May 12, 2007

Q & A by Akhilesh

->>How to open a page in New Window
There was a problem with me in very initial time. I forgot how to open a new webpage in new window. I Look into google but I got suggestion for javascript codes. But by help of my Senior Mr. Ullas I got the solution. That is bellow:-
you have to put your uri with target="_blank" inside the anchor. Like


target="_blank" href="URI"