| |

VerySource

 Forgot password?
 Register
Search
View: 772|Reply: 3

Problems downloading files from ORACLE database ??? Urgent ~

[Copy link]

1

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-1-2 22:40:01
| Show all posts |Read mode
I used the following code to download and the process did not report an error
But the downloaded stuff is always 86 bytes, and it is always garbled when opened. Why is this?
Please help .. thanks
Class.forName ("oracle.jdbc.driver.OracleDriver"). NewInstance ();
    String url = "jdbc: oracle: thin: @ 192.168.31.109: 1521: iasdb";
    // orcl is the SID of your database
    String user = "news";
    String password = "up722006";
    String name = "xxx";
    Connection conn = DriverManager.getConnection (url, user, password);
    
    PreparedStatement st = conn.prepareStatement ("select up_file from test where name =?");
      st.setString (1, name);
      // ResultSet rs = st.executeQuery ();
      ResultSet rs = st.executeQuery ();
      if (rs.next ())
      {
      byte [] cnt = rs.getBytes ("up_file");
      System.out.print ("here");
      response.getOutputStream (). write (cnt);
      System.out.print ("hehe");
      }
    }
Reply

Use magic Report

1

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

 Author| Post time: 2020-1-3 10:36:01
| Show all posts
Does anyone know? 55555555555555555555
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-7-14 19:00:01
| Show all posts
Is the file binary? In this case, it is over when it encounters 0.
Reply

Use magic Report

0

Threads

16

Posts

11.00

Credits

Newbie

Rank: 1

Credits
11.00

 China

Post time: 2020-7-14 22:30:01
| Show all posts
mstrBackName = result.getString("randomname");
mstrfileName = result.getString("markname");
pintid = result.getInt("id");
InputStream inStream=result.getBinaryStream("MarkBody");
String aa=getServletContext().getRealPath("/")+"upload/showFile/";
FileOutputStream fs=new FileOutputStream(aa+mstrBackName);
if(mstrBackName!=null&&mstrBackName!="")
{
byte[] buffer =new byte[1444];
while ((int byteread=inStream.read(buffer))!=-1)
{
fs.write(buffer,0,byteread);
}
}
You try to change yours according to this
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list